CC-5555 : Implement simple caching for preferences

using apc to save/fetch preferences to/from a cache.
This commit is contained in:
Naomi 2013-11-11 15:07:13 -05:00
parent 050d984882
commit f45708682f
3 changed files with 60 additions and 12 deletions

View file

@ -0,0 +1,26 @@
<?php
class Cache
{
private function createCacheKey($key, $userId = null) {
$CC_CONFIG = Config::getConfig();
$a = $CC_CONFIG["apiKey"][0];
$cacheKey = "{$key}{$userId}{$a}";
return $cacheKey;
}
public function store($key, $value, $userId = null) {
$cacheKey = self::createCacheKey($key, $userId);
return apc_store($cacheKey, $value);
}
public function fetch($key, $userId = null) {
$cacheKey = self::createCacheKey($key, $userId);
return apc_fetch($cacheKey);
}
}