Skip to content

Commit

Permalink
Updated Cache functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed Jul 3, 2022
1 parent 3e160fd commit 30778de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 5 additions & 1 deletion public_html/lib-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@
Log::init($_CONF['path_log']);

// Load Cache class
Cache::init(new Cache\FileSystem($_CONF['path'] . 'data/cache/'));
if (is_callable('apcu_store')) {
Cache::init(new Cache\APCu());
} else {
Cache::init(new Cache\FileSystem($_CONF['path'] . 'data/cache/'));
}

// Load in Geeklog Variables Table

Expand Down
9 changes: 4 additions & 5 deletions system/classes/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public static function init(CacheInterface $driver)
{
if (!self::$isInitialized) {
self::$instance = $driver;
// self::$instance = new APCu();
self::$isInitialized = true;
}
}
Expand Down Expand Up @@ -96,7 +95,7 @@ public static function get($key, $defaultValue = null)
*/
public static function set($key, $data, $ttl = 0)
{
return self::$isEnabled ? self::$instance->set($key, $data, $ttl) : false;
return self::$isEnabled && self::$instance->set($key, $data, $ttl);
}

/**
Expand All @@ -109,7 +108,7 @@ public static function set($key, $data, $ttl = 0)
*/
public static function add($key, $data, $ttl = 0)
{
return self::$isEnabled ? self::$instance->add($key, $data, $ttl) : false;
return self::$isEnabled && self::$instance->add($key, $data, $ttl);
}

/**
Expand All @@ -120,7 +119,7 @@ public static function add($key, $data, $ttl = 0)
*/
public static function delete($key)
{
return self::$isEnabled ? self::$instance->delete($key) : false;
return self::$isEnabled && self::$instance->delete($key);
}

/**
Expand All @@ -131,7 +130,7 @@ public static function delete($key)
*/
public static function exists($key)
{
return self::$isEnabled ? self::$instance->exists($key) : false;
return self::$isEnabled && self::$instance->exists($key);
}

/**
Expand Down

0 comments on commit 30778de

Please sign in to comment.