1: <?php
2:
3: namespace Psr\Cache;
4:
5: /**
6: * CacheItemPoolInterface generates CacheItemInterface objects.
7: */
8: interface CacheItemPoolInterface
9: {
10: /**
11: * Returns a Cache Item representing the specified key.
12: *
13: * This method must always return a CacheItemInterface object, even in case of
14: * a cache miss. It MUST NOT return null.
15: *
16: * The key for which to return the corresponding Cache Item.
17: * If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException
18: * MUST be thrown.
19: * The corresponding Cache Item.
20: *
21: * @param string $key
22: *
23: * @throws InvalidArgumentException
24: *
25: * @return CacheItemInterface
26: */
27: public function getItem($key);
28:
29: /**
30: * Returns a traversable set of cache items.
31: *
32: * An indexed array of keys of items to retrieve.
33: * If any of the keys in $keys are not a legal value a \Psr\Cache\InvalidArgumentException
34: * MUST be thrown.
35: * A traversable collection of Cache Items keyed by the cache keys of
36: * each item. A Cache item will be returned for each key, even if that
37: * key is not found. However, if no keys are specified then an empty
38: * traversable MUST be returned instead.
39: *
40: * @param array $keys
41: *
42: * @throws InvalidArgumentException
43: *
44: * @return array|\Traversable
45: */
46: public function getItems(array $keys = array());
47:
48: /**
49: * Confirms if the cache contains specified cache item.
50: *
51: * Note: This method MAY avoid retrieving the cached value for performance reasons.
52: * This could result in a race condition with CacheItemInterface::get(). To avoid
53: * such situation use CacheItemInterface::isHit() instead.
54: *
55: * The key for which to check existence.
56: * If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException
57: * MUST be thrown.
58: * True if item exists in the cache, false otherwise.
59: *
60: * @param string $key
61: *
62: * @throws InvalidArgumentException
63: *
64: * @return bool
65: */
66: public function hasItem($key);
67:
68: /**
69: * Deletes all items in the pool.
70: *
71: * True if the pool was successfully cleared. False if there was an error.
72: *
73: * @return bool
74: */
75: public function clear();
76:
77: /**
78: * Removes the item from the pool.
79: *
80: * The key for which to delete
81: * If the $key string is not a legal value a \Psr\Cache\InvalidArgumentException
82: * MUST be thrown.
83: * True if the item was successfully removed. False if there was an error.
84: *
85: * @param string $key
86: *
87: * @throws InvalidArgumentException
88: *
89: * @return bool
90: */
91: public function deleteItem($key);
92:
93: /**
94: * Removes multiple items from the pool.
95: *
96: * An array of keys that should be removed from the pool.
97: * If any of the keys in $keys are not a legal value a \Psr\Cache\InvalidArgumentException
98: * MUST be thrown.
99: * True if the items were successfully removed. False if there was an error.
100: *
101: * @param array $keys
102: *
103: * @throws InvalidArgumentException
104: *
105: * @return bool
106: */
107: public function deleteItems(array $keys);
108:
109: /**
110: * Persists a cache item immediately.
111: *
112: * The cache item to save.
113: * True if the item was successfully persisted. False if there was an error.
114: *
115: * @param CacheItemInterface $item
116: *
117: * @return bool
118: */
119: public function save(CacheItemInterface $item);
120:
121: /**
122: * Sets a cache item to be persisted later.
123: *
124: * The cache item to save.
125: * False if the item could not be queued or if a commit was attempted and failed. True otherwise.
126: *
127: * @param CacheItemInterface $item
128: *
129: * @return bool
130: */
131: public function saveDeferred(CacheItemInterface $item);
132:
133: /**
134: * Persists any deferred cache items.
135: *
136: * True if all not-yet-saved items were successfully saved or there were none. False otherwise.
137: *
138: * @return bool
139: */
140: public function commit();
141: }
142: