/
interface.namespacedcache.php
87 lines (82 loc) · 3.2 KB
/
interface.namespacedcache.php
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* @package interface
*/
/**
* This interface is to be implemented by Extensions who wish to provide
* cacheable objects for Symphony to use and whose cache providers support
* namespacing to make bulk read, writes and deletes.
*
* @since Symphony 2.6.0
*/
interface iNamespacedCache
{
/**
* Returns the human readable name of this cache type. This is
* displayed in the system preferences cache options.
*
* @return string
*/
public static function getName();
/**
* This function returns all the settings of the current Cache
* instance.
*
* @return array
* An associative array of settings for this cache where the
* key is `getClass` and the value is an associative array of settings,
* key being the setting name, value being, the value
*/
public function settings();
/**
* Given the hash of a some data, check to see whether it exists in
* `tbl_cache`. If no cached object is found, this function will return
* false, otherwise the cached object will be returned as an array.
*
* @param string $hash
* The hash of the Cached object, as defined by the user
* @param string $namespace
* The namespace allows a group of data to be retrieved at once
* @return array|boolean
* An associative array of the cached object including the creation time,
* expiry time, the hash and the data. If the object is not found, false will
* be returned.
*/
public function read($hash, $namespace = null);
/**
* This function will compress data for storage in `tbl_cache`.
* It is left to the user to define a unique hash for this data so that it can be
* retrieved in the future. Optionally, a `$ttl` parameter can
* be passed for this data. If this is omitted, it data is considered to be valid
* forever. This function utilizes the Mutex class to act as a crude locking
* mechanism.
*
* @see toolkit.Mutex
* @param string $hash
* The hash of the Cached object, as defined by the user
* @param string $data
* The data to be cached, this will be compressed prior to saving.
* @param integer $ttl
* A integer representing how long the data should be valid for in minutes.
* By default this is null, meaning the data is valid forever
* @param string $namespace
* The namespace allows data to be grouped and saved so it can be
* retrieved later.
* @return boolean
* If an error occurs, this function will return false otherwise true
*/
public function write($hash, $data, $ttl = null, $namespace = null);
/**
* Given the hash of a cacheable object, remove it from `tbl_cache`
* regardless of if it has expired or not. If no $hash is given,
* this removes all cache objects from `tbl_cache` that have expired.
* After removing, the function uses the `__optimise` function
*
* @see core.Cacheable#optimise()
* @param string $hash
* The hash of the Cached object, as defined by the user
* @param string $namespace
* The namespace allows similar data to be deleted quickly.
*/
public function delete($hash, $namespace = null);
}