class-wpml-wp-cache-item.php
811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
class WPML_WP_Cache_Item {
/** @var string $key */
private $key;
/** @var WPML_WP_Cache $cache */
private $cache;
/**
* WPML_WP_Cache_Item constructor.
*
* @param WPML_WP_Cache $cache
* @param string|array $key
*/
public function __construct( WPML_WP_Cache $cache, $key ) {
if ( is_array( $key ) ) {
$key = md5( (string) json_encode( $key ) );
}
$this->cache = $cache;
$this->key = $key;
}
/**
* @return bool
*/
public function exists() {
$found = false;
$this->cache->get( $this->key, $found );
return $found;
}
/**
* @return mixed
*/
public function get() {
$found = false;
return $this->cache->get( $this->key, $found );
}
/**
* @param mixed $value
*/
public function set( $value ) {
$this->cache->set( $this->key, $value );
}
}