CC-5555 : Implement simple caching for preferences
using apc to save/fetch preferences to/from a cache.
This commit is contained in:
parent
050d984882
commit
f45708682f
3 changed files with 60 additions and 12 deletions
26
airtime_mvc/application/models/Cache.php
Normal file
26
airtime_mvc/application/models/Cache.php
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue