| @@ 51-82 (lines=32) @@ | ||
| 48 | /** |
|
| 49 | * @inheritdoc |
|
| 50 | */ |
|
| 51 | public function get($key) |
|
| 52 | { |
|
| 53 | static $memcacheCache = array(); |
|
| 54 | static $memcacheCacheCounter = array(); |
|
| 55 | $staticCacheCounterHelper = 5; |
|
| 56 | ||
| 57 | if (!isset($memcacheCacheCounter[$key])) { |
|
| 58 | $memcacheCacheCounter[$key] = 0; |
|
| 59 | } |
|
| 60 | ||
| 61 | if ($memcacheCacheCounter[$key] < ($staticCacheCounterHelper + 1)) { |
|
| 62 | $memcacheCacheCounter[$key]++; |
|
| 63 | } |
|
| 64 | ||
| 65 | if (array_key_exists($key, $memcacheCache) === true) { |
|
| 66 | ||
| 67 | // get from static-cache |
|
| 68 | return $memcacheCache[$key]; |
|
| 69 | ||
| 70 | } else { |
|
| 71 | ||
| 72 | // get from cache-adapter |
|
| 73 | $return = $this->memcache->get($key); |
|
| 74 | ||
| 75 | // save into static-cache |
|
| 76 | if ($memcacheCacheCounter[$key] >= $staticCacheCounterHelper) { |
|
| 77 | $memcacheCache[$key] = $return; |
|
| 78 | } |
|
| 79 | ||
| 80 | return $return; |
|
| 81 | } |
|
| 82 | } |
|
| 83 | ||
| 84 | /** |
|
| 85 | * @inheritdoc |
|
| @@ 48-79 (lines=32) @@ | ||
| 45 | /** |
|
| 46 | * @inheritdoc |
|
| 47 | */ |
|
| 48 | public function get($key) |
|
| 49 | { |
|
| 50 | static $memcacheCache = array(); |
|
| 51 | static $memcacheCacheCounter = array(); |
|
| 52 | $staticCacheCounterHelper = 5; |
|
| 53 | ||
| 54 | if (!isset($memcacheCacheCounter[$key])) { |
|
| 55 | $memcacheCacheCounter[$key] = 0; |
|
| 56 | } |
|
| 57 | ||
| 58 | if ($memcacheCacheCounter[$key] <= ($staticCacheCounterHelper + 1)) { |
|
| 59 | $memcacheCacheCounter[$key]++; |
|
| 60 | } |
|
| 61 | ||
| 62 | if (array_key_exists($key, $memcacheCache) === true) { |
|
| 63 | ||
| 64 | // get from static-cache |
|
| 65 | return $memcacheCache[$key]; |
|
| 66 | ||
| 67 | } else { |
|
| 68 | ||
| 69 | // get from cache-adapter |
|
| 70 | $return = $this->memcached->get($key); |
|
| 71 | ||
| 72 | // save into static-cache |
|
| 73 | if ($memcacheCacheCounter[$key] >= $staticCacheCounterHelper) { |
|
| 74 | $memcacheCache[$key] = $return; |
|
| 75 | } |
|
| 76 | ||
| 77 | return $return; |
|
| 78 | } |
|
| 79 | } |
|
| 80 | ||
| 81 | /** |
|
| 82 | * @inheritdoc |
|