1 | <?php |
||
31 | trait CacheItemAwareTrait |
||
32 | { |
||
33 | /** |
||
34 | * item factory method, signatures as follows |
||
35 | * |
||
36 | * function( |
||
37 | * string $key, |
||
38 | * CachePool $driver, |
||
39 | * array $properties = [] |
||
40 | * ): CacheItemInterface |
||
41 | * |
||
42 | * @var callable |
||
43 | * @access protected |
||
44 | */ |
||
45 | protected $item_factory; |
||
46 | |||
47 | /** |
||
48 | * Local cache of generated CacheItemInterface |
||
49 | * |
||
50 | * @var CacheItemExtendedInterface[] |
||
51 | * @access protected |
||
52 | */ |
||
53 | protected $item_cache; |
||
54 | |||
55 | /** |
||
56 | * Use local cache for generated item |
||
57 | * |
||
58 | * @var bool |
||
59 | * @access protected |
||
60 | */ |
||
61 | protected $use_item_cache = false; |
||
62 | |||
63 | /** |
||
64 | * Set cache item factory callable |
||
65 | * |
||
66 | * @param callable $itemFactory |
||
67 | * @return $this |
||
68 | * @access public |
||
69 | */ |
||
70 | public function setItemFactory(callable $itemFactory = null) |
||
75 | |||
76 | /** |
||
77 | * Get a cache item |
||
78 | * |
||
79 | * @param string $key |
||
80 | * @return CacheItemExtendedInterface |
||
81 | * @throws InvalidArgumentException if $key is invalid |
||
82 | * @access protected |
||
83 | */ |
||
84 | protected function getCacheItem(/*# string */ $key)/*# : CacheItemExtendedInterface */ |
||
99 | |||
100 | /** |
||
101 | * Create a cache item on the fly |
||
102 | * |
||
103 | * @param string $key |
||
104 | * @return CacheItemExtendedInterface |
||
105 | * @access protected |
||
106 | */ |
||
107 | protected function createCacheItem(/*# string */ $key)/*# : CacheItemExtendedInterface */ |
||
118 | |||
119 | /** |
||
120 | * Validate key string |
||
121 | * |
||
122 | * @param string &$key key to check |
||
123 | * @return void |
||
124 | * @throws InvalidArgumentException |
||
125 | * @access protected |
||
126 | */ |
||
127 | protected function validateKey(/*# string */ &$key) |
||
141 | } |
||
142 |