diff --git a/common/autoload.php b/common/autoload.php index 783fe1a52..d1720fc07 100644 --- a/common/autoload.php +++ b/common/autoload.php @@ -202,3 +202,8 @@ Rhymix\Framework\Debug::registerErrorHandlers(error_reporting()); */ $internal_timezone = Rhymix\Framework\DateTime::getTimezoneNameByOffset(config('locale.internal_timezone')); date_default_timezone_set($internal_timezone); + +/** + * Initialize the cache handler. + */ +Rhymix\Framework\Cache::init(Rhymix\Framework\Config::get('cache')); diff --git a/common/framework/cache.php b/common/framework/cache.php new file mode 100644 index 000000000..3ccf075ac --- /dev/null +++ b/common/framework/cache.php @@ -0,0 +1,247 @@ +incr(self::getRealKey('#GROUP:' . $group_name . ':v'), 1) ? true : false; + } + else + { + return false; + } + } + + /** + * Clear all keys from the cache. + * + * This method returns true on success and false on failure. + * + * @return bool + */ + public static function clearAll() + { + if (self::$_driver !== null) + { + return self::$_driver->clear() ? true : false; + } + else + { + return false; + } + } + + /** + * Get the actual key used by Rhymix. + * + * @param string $key + * @param string $group_name (optional) + * @return string + */ + public static function getRealKey($key, $group_name = null) + { + if ($group_name) + { + $group_version = intval(self::get('#GROUP:' . $group_name . ':v')); + return self::getCachePrefix() . '#GROUP:' . $group_name . ':' . $group_version . ':' . $key; + } + else + { + return self::getCachePrefix() . $key; + } + } +} diff --git a/common/framework/drivers/cacheinterface.php b/common/framework/drivers/cacheinterface.php new file mode 100644 index 000000000..117e67d45 --- /dev/null +++ b/common/framework/drivers/cacheinterface.php @@ -0,0 +1,113 @@ +