Skip to content

Commit

Permalink
update redis
Browse files Browse the repository at this point in the history
  • Loading branch information
miftahurrahmi committed Nov 22, 2023
1 parent 2f8b50d commit 7486c45
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Helpers/Redis/ConfigurationRedis.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ class ConfigurationRedis
public static $badaso_configuration_redis_key = 'badaso_configuration_redis_key';

// save data configuration to redis
public static function save()
public static function save($model_configurations)
{
$model_configurations = Configuration::all();
try {
Redis::set(self::$badaso_configuration_redis_key, serialize($model_configurations));
} catch (\Exception $th) {
Expand All @@ -27,9 +26,15 @@ public static function get()
$result = [];
try {
$configuration_from_redis = Redis::get(self::$badaso_configuration_redis_key);
$result = unserialize($configuration_from_redis);
if ($configuration_from_redis) {
$result = unserialize($configuration_from_redis);
} else {
$result = Configuration::all();
self::save($result);
}
} catch (\Exception $th) {
$result = Configuration::all();
self::save($result);
}

return $result;
Expand Down

0 comments on commit 7486c45

Please sign in to comment.