PluginProbe
Parse.ly / 3.14.2
Parse.ly v3.14.2
3.24.1 3.24.0 3.23.7 3.23.6 3.23.5 3.23.4 3.23.3 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.17.0 3.18.0 3.18.1 3.19.0 3.19.1 3.19.2 3.19.3 3.2.0 3.2.1 3.20.0 3.20.1 3.20.2 3.20.3 All 105 releases
wp-parsely / src / RemoteAPI / class-wordpress-cache.php

class-wordpress-cache.php in Parse.ly 3.14.2, at src/RemoteAPI/class-wordpress-cache.php

53 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Remote API: Adapter class for the WordPress Object Cache
4 *
5 * @package Parsely
6 * @since 3.2.0
7 */
8
9 declare(strict_types=1);
10
11 namespace Parsely\RemoteAPI;
12
13 /**
14 * Remote API Adapter for the WordPress Object Cache.
15 */
16 class WordPress_Cache implements Cache {
17
18 /**
19 * Retrieves the cache contents from the cache by key and group.
20 *
21 * @since 3.2.0
22 *
23 * @param int|string $key The key under which the cache contents are stored.
24 * @param string $group Optional. Where the cache contents are grouped. Default empty.
25 * @param bool $force Optional. Whether to force an update of the local cache
26 * from the persistent cache. Default false.
27 * @param bool $found Optional. Whether the key was found in the cache (passed by reference).
28 * Disambiguates a return of false, a storable value. Default null.
29 * @return mixed|false The cache contents on success, false on failure to retrieve contents.
30 */
31 public function get( $key, string $group = '', bool $force = false, bool $found = null ) {
32 return wp_cache_get( $key, $group, $force, $found );
33 }
34
35 /**
36 * Saves the data to the cache.
37 *
38 * @since 3.2.0
39 *
40 * @param int|string $key The cache key to use for retrieval later.
41 * @param mixed $data The contents to store in the cache.
42 * @param string $group Optional. Where to group the cache contents. Enables the same key
43 * to be used across groups. Default empty.
44 * @param int $expire Optional. When to expire the cache contents, in seconds.
45 * Default 0 (no expiration).
46 * @return bool True on success, false on failure.
47 */
48 public function set( $key, $data, string $group = '', $expire = 0 ): bool {
49 // phpcs:ignore WordPressVIPMinimum.Performance.LowExpiryCacheTime.CacheTimeUndetermined
50 return wp_cache_set( $key, $data, $group, $expire );
51 }
52 }
53