PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / 1.4.0
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution v1.4.0
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / Performance / Storage / Contracts / Storage.php

Storage.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution 1.4.0, at src/Performance/Storage/Contracts/Storage.php

75 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The Storage contract that storage drivers should implement.
4 *
5 * @package SolidWP\Performance
6 */
7
8 declare( strict_types=1 );
9
10 namespace SolidWP\Performance\Storage\Contracts;
11
12 use Closure;
13 use SolidWP\Performance\Storage\Exceptions\InvalidKeyException;
14
15 /**
16 * The Storage contract that storage drivers should implement.
17 *
18 * @package SolidWP\Performance
19 */
20 interface Storage {
21
22 /**
23 * Put a value in storage.
24 *
25 * @param string|int|float|mixed[]|object $key The storage key. Accepts any variable that can be json encoded.
26 * @param mixed $value The value to store.
27 * @param int $expire The storage lifespan in seconds.
28 *
29 * @throws InvalidKeyException If passed an invalid storage key.
30 */
31 public function set( $key, $value, int $expire = 0 ): bool;
32
33 /**
34 * Get a value from storage.
35 *
36 * @param string|int|float|mixed[]|object $key The storage key. Accepts any variable that can be json encoded.
37 *
38 * @throws InvalidKeyException If passed an invalid storage key.
39 *
40 * @return null|mixed Returns null if we can't find the storage value.
41 */
42 public function get( $key );
43
44 /**
45 * Delete a value from storage.
46 *
47 * @param string|int|float|mixed[]|object $key The storage key.
48 *
49 * @throws InvalidKeyException If passed an invalid storage key.
50 */
51 public function delete( $key ): bool;
52
53 /**
54 * Get an item from storage, or execute the given Closure and store the result.
55 *
56 * @param string|int|float|mixed[]|object $key The storage key.
57 * @param Closure $callback The callback used to generate and store the value.
58 * @param int $expire The storage lifespan in seconds.
59 *
60 * @throws InvalidKeyException If passed an invalid storage key.
61 *
62 * @return mixed The storage value.
63 */
64 public function remember( $key, Closure $callback, int $expire = 0 );
65
66 /**
67 * Retrieve an item from storage and delete it.
68 *
69 * @param string|int|float|mixed[]|object $key The storage key.
70 *
71 * @throws InvalidKeyException If passed an invalid storage key.
72 */
73 public function pull( $key );
74 }
75