PluginProbe
Assistant – Every Day Productivity Apps / trunk
Assistant – Every Day Productivity Apps vtrunk
1.5.5 trunk 0.1.0 0.2.0 0.2.1 0.2.2 0.3.0 0.3.1 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.7.0 0.7.0.2 0.7.0.3 0.7.0.4 0.7.0.5 0.7.0.6 0.7.0.7 0.7.0.8 0.7.0.9 0.7.1 1.0 All 71 releases
assistant / backend / src / System / Container / ReflectionCacheApc.php

ReflectionCacheApc.php in Assistant – Every Day Productivity Apps trunk, at backend/src/System/Container/ReflectionCacheApc.php

38 lines 938 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FL\Assistant\System\Container;
4
5 class ReflectionCacheApc implements ReflectionCache {
6
7 private $localCache;
8 private $timeToLive = 5;
9
10 public function __construct( ReflectionCache $localCache = null ) {
11 $this->localCache = $localCache ?: new ReflectionCacheArray;
12 }
13
14 public function setTimeToLive( $seconds ) {
15 $seconds = (int) $seconds;
16 $this->timeToLive = ( $seconds > 0 ) ? $seconds : $this->timeToLive;
17
18 return $this;
19 }
20
21 public function fetch( $key ) {
22 $localData = $this->localCache->fetch( $key );
23
24 if ( $localData != false ) {
25 return $localData;
26 } else {
27 $success = null; // stupid by-ref parameter that scrutinizer complains about
28 $data = apc_fetch( $key, $success );
29 return $success ? $data : false;
30 }
31 }
32
33 public function store( $key, $data ) {
34 $this->localCache->store( $key, $data );
35 apc_store( $key, $data, $this->timeToLive );
36 }
37 }
38