PluginProbe
seQura / trunk
seQura vtrunk
4.3.4 4.3.3 4.3.2 4.3.1 trunk 2.0.0 2.0.10 2.0.11 2.0.12 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0.0 3.0.2 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 4.0.0 All 30 releases
sequra / src / Repositories / interface-cache-repository.php

interface-cache-repository.php in seQura trunk, at src/Repositories/interface-cache-repository.php

68 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Cache repository interface.
4 *
5 * @package SeQura/WC
6 * @subpackage SeQura/WC/Repositories
7 */
8
9 namespace SeQura\WC\Repositories;
10
11 /**
12 * Provides caching capabilities with a two-level strategy:
13 * WordPress object cache (persistent when Redis/Memcached is configured)
14 * backed by a static in-memory array for per-request fast path.
15 */
16 interface Interface_Cache_Repository {
17
18 /**
19 * Get a value from the cache.
20 *
21 * @param string $key Cache key.
22 * @param string $group Cache group.
23 * @param bool $found Whether the key was found in the cache. Passed by reference.
24 * Distinguishes between a cached false/0 value and a cache miss.
25 *
26 * @return mixed Cached value, or false on miss.
27 */
28 public function get( $key, $group, &$found = false );
29
30 /**
31 * Set a value in the cache.
32 *
33 * @param string $key Cache key.
34 * @param mixed $value Value to store. Must be serializable.
35 * @param string $group Cache group.
36 * @param int $ttl Time to live in seconds. 0 means no expiration (only applies to persistent backends).
37 */
38 public function set( $key, $value, $group, $ttl = 0 ): bool;
39
40 /**
41 * Delete a value from the cache.
42 *
43 * @param string $key Cache key.
44 * @param string $group Cache group.
45 */
46 public function delete( $key, $group ): bool;
47
48 /**
49 * Atomically increment a numeric value in the cache.
50 *
51 * Uses wp_cache_incr() which is atomic on Redis/Memcached backends,
52 * eliminating the read-then-write race of get()+set().
53 * If the key does not exist it is initialised to 1 with the given TTL.
54 *
55 * @param string $key Cache key.
56 * @param string $group Cache group.
57 * @param int $ttl TTL used only when the key is first created. 0 = no expiration.
58 *
59 * @return int New value after increment.
60 */
61 public function increment( $key, $group, $ttl = 0 ): int;
62
63 /**
64 * Flush all cached data from both the static in-memory array and the WordPress object cache.
65 */
66 public function flush(): void;
67 }
68