Last active
August 29, 2015 14:02
-
-
Save jeremeamia/22f1ddbdab5fd2439c2f to your computer and use it in GitHub Desktop.
Why can't we just do a simple cache interface?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Psr\Cache | |
| { | |
| interface CacheInterface | |
| { | |
| public function get($key, &$isHit); #: mixed | |
| // Note: $isHit is populated with `true` on hit or `false` on miss. This | |
| // is a simple way to distinguish between falsey values and cache misses. | |
| public function has($key); #: bool | |
| public function save($key, $value, $ttl = null); #: bool | |
| public function delete($key); #: bool | |
| } | |
| // This additional interface could be for batching gets/saves, etc. | |
| interface MultiValueCacheInterface | |
| { | |
| public function getMultiple(array $keys); #: array | |
| public function saveMultiple(array $values, $ttl = null); #: bool | |
| public function deleteMultiple(array $keys); #: bool | |
| public function clear(); #: bool | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment