sintonia/airtime_mvc/application/models/Cache.php
Naomi f45708682f CC-5555 : Implement simple caching for preferences
using apc to save/fetch preferences to/from a cache.
2013-11-11 15:07:13 -05:00

26 lines
No EOL
505 B
PHP

<?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);
}
}