1 | <?php |
||
33 | trait CacheAdapterTrait |
||
34 | { |
||
35 | |||
36 | /** |
||
37 | * Query whether or not a cache value for the passed cache key is available. |
||
38 | * |
||
39 | * @param string $key The cache key to query for |
||
40 | * |
||
41 | * @return boolean TRUE if the a value is available, else FALSE |
||
42 | */ |
||
43 | abstract public function isCached($key); |
||
44 | |||
45 | /** |
||
46 | * Inversion of the isCached() method. |
||
47 | * |
||
48 | * @param string $key The cache key to query for |
||
49 | * |
||
50 | * @return boolean TRUE if the value is not available, else FALSE |
||
51 | */ |
||
52 | abstract public function notCached($key); |
||
53 | |||
54 | /** |
||
55 | * Add the passed item to the cache. |
||
56 | * |
||
57 | * @param string $key The cache key to use |
||
58 | * @param mixed $value The value that has to be cached |
||
59 | * @param array $references An array with references to add |
||
60 | * @param array $tags An array with tags to add |
||
61 | * @param boolean $override Flag that allows to override an exising cache entry |
||
62 | * @param integer $time The TTL in seconds for the passed item |
||
63 | * |
||
64 | * @return void |
||
65 | */ |
||
66 | abstract public function toCache($key, $value, array $references = array(), array $tags = array(), $override = false, $time = null); |
||
67 | |||
68 | /** |
||
69 | * Returns a new cache item for the passed key |
||
70 | * |
||
71 | * @param string $key The cache key to return the item for |
||
72 | * |
||
73 | * @return mixed The value for the passed key |
||
74 | */ |
||
75 | abstract public function fromCache($key); |
||
76 | |||
77 | /** |
||
78 | * Raises the value for the attribute with the passed key by one. |
||
79 | * |
||
80 | * @param mixed $key The key of the attribute to raise the value for |
||
81 | * @param mixed $counterName The name of the counter to raise |
||
82 | * |
||
83 | * @return integer The counter's new value |
||
84 | */ |
||
85 | public function raiseCounter($key, $counterName) |
||
103 | |||
104 | /** |
||
105 | * This method merges the passed attributes with an array that |
||
106 | * has already been added under the passed key. |
||
107 | * |
||
108 | * If no value will be found under the passed key, the attributes |
||
109 | * will simply be registered. |
||
110 | * |
||
111 | * @param mixed $key The key of the attributes that has to be merged with the passed ones |
||
112 | * @param array $attributes The attributes that has to be merged with the exising ones |
||
113 | * |
||
114 | * @return void |
||
115 | * @throws \Exception Is thrown, if the already registered value is no array |
||
116 | * @link http://php.net/array_replace_recursive |
||
117 | */ |
||
118 | public function mergeAttributesRecursive($key, array $attributes) |
||
141 | } |
||
142 |