- $setting = $this->getSettingObjectByKey($key);
- $value = $setting === null ? null : $setting->value;
+ $value = $this->getValueFromStore($key, $default);
+ return $this->formatValue($value, $default);
+ }
+
+ /**
+ * Gets a setting value from the cache or database.
+ * @param $key
+ * @param $default
+ * @return mixed
+ */
+ protected function getValueFromStore($key, $default)
+ {
+ $cacheKey = $this->cachePrefix . $key;
+ if ($this->cache->has($cacheKey)) {
+ return $this->cache->get($cacheKey);
+ }
+
+ $settingObject = $this->getSettingObjectByKey($key);
+ if($settingObject !== null) {
+ $value = $settingObject->value;
+ $this->cache->forever($cacheKey, $value);
+ return $value;
+ }