diff --git a/common/framework/cache.php b/common/framework/cache.php index 5a477509d..e8718ef24 100644 --- a/common/framework/cache.php +++ b/common/framework/cache.php @@ -230,18 +230,17 @@ class Cache * * @param string $key * @param string $group_name (optional) + * @param bool $add_prefix (optional) * @return string */ - public static function getRealKey($key, $group_name = null) + public static function getRealKey($key, $group_name = null, $add_prefix = true) { 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; + $key = '#GROUP:' . $group_name . ':' . $group_version . ':' . $key; } + + return ($add_prefix ? self::getCachePrefix() : '') . $key; } } diff --git a/common/framework/drivers/cache/file.php b/common/framework/drivers/cache/file.php index 9e129286e..8d3ce0cdd 100644 --- a/common/framework/drivers/cache/file.php +++ b/common/framework/drivers/cache/file.php @@ -95,7 +95,7 @@ class File implements \Rhymix\Framework\Drivers\CacheInterface */ public function set($key, $value, $ttl) { - return Storage::writePHPData($this->_getFilename($key), array($ttl ? (time() + $ttl) : 0, $value)); + return Storage::writePHPData($this->_getFilename($key), array($ttl ? (time() + $ttl) : 0, $value), $key); } /** diff --git a/common/framework/storage.php b/common/framework/storage.php index daee9dd9e..0d5530bec 100644 --- a/common/framework/storage.php +++ b/common/framework/storage.php @@ -259,11 +259,16 @@ class Storage * * @param string $filename * @param mixed $data + * @param string $comment (optional) * @return string|false */ - public static function writePHPData($filename, $data) + public static function writePHPData($filename, $data, $comment = null) { - return self::write($filename, '<' . '?php return unserialize(' . var_export(serialize($data), true) . ');'); + if ($comment !== null) + { + $comment = "/* $comment */\n"; + } + return self::write($filename, '<' . '?php ' . $comment . 'return unserialize(' . var_export(serialize($data), true) . ');'); } /**