| 1 | <?php |
| 2 | |
| 3 | namespace Wikimedia\WRStats; |
| 4 | |
| 5 | /** |
| 6 | * Narrow interface for WRStatsFactory to a memcached-like key-value store. |
| 7 | * |
| 8 | * @since 1.39 |
| 9 | */ |
| 10 | interface StatsStore { |
| 11 | /** |
| 12 | * Construct a string key from its components |
| 13 | * |
| 14 | * @param string[] $prefix The prefix components. |
| 15 | * @param array<string|int> $internals The internal components. |
| 16 | * @param EntityKey $entity The entity components. If $entity->isGlobal() |
| 17 | * is true, the key as a whole should be treated as global. |
| 18 | * @return string |
| 19 | */ |
| 20 | public function makeKey( $prefix, $internals, $entity ); |
| 21 | |
| 22 | /** |
| 23 | * Perform a batch of increment operations. |
| 24 | * |
| 25 | * @param int[] $values The deltas to add, indexed by the key as returned by makeKey() |
| 26 | * @param int $ttl The expiry time of any new entries, in seconds. This is |
| 27 | * a hint, allowing the storage layer to control space usage. Implementing |
| 28 | * expiry is not a requirement. |
| 29 | */ |
| 30 | public function incr( array $values, $ttl ); |
| 31 | |
| 32 | /** |
| 33 | * Perform a batch of delete operations. |
| 34 | * |
| 35 | * @param string[] $keys Keys to delete; strings returned by makeKey() |
| 36 | */ |
| 37 | public function delete( array $keys ); |
| 38 | |
| 39 | /** |
| 40 | * Perform a batch of fetch operations. |
| 41 | * |
| 42 | * @param string[] $keys Keys to get; strings returned by makeKey() |
| 43 | * @return int[] Integers |
| 44 | */ |
| 45 | public function query( array $keys ); |
| 46 | } |