1: <?php
2:
3: /**
4: * abstract cache provider
5: */
6: abstract class QAbstractCacheProvider {
7: /**
8: * Get the object that has the given key from the cache
9: * @param string $strKey the key of the object in the cache
10: * @return object
11: */
12: abstract public function Get($strKey);
13:
14: /**
15: * Set the object into the cache with the given key
16: * @param string $strKey the key to use for the object
17: * @param object $objValue the object to put in the cache
18: * @return void
19: */
20: abstract public function Set($strKey, $objValue);
21:
22: /**
23: * Delete the object that has the given key from the cache
24: * @param string $strKey the key of the object in the cache
25: * @return void
26: */
27: abstract public function Delete($strKey);
28:
29: /**
30: * Invalidate all the objects in the cache
31: * @return void
32: */
33: abstract public function DeleteAll();
34:
35: /**
36: * Create a key appropriate for this cache provider
37: * @return string the key
38: */
39: public function CreateKey(/* ... */) {
40: // @hack for php version < 5.4
41: $objArgsArray = array();
42: $arg_list = func_get_args();
43: $numargs = func_num_args();
44: for ($i = 0; $i < $numargs; $i++) {
45: $arg = $arg_list[$i];
46: if (is_array($arg)) {
47: foreach ($arg as $a) {
48: $objArgsArray[] = $a;
49: }
50: } else {
51: $objArgsArray[] = $arg;
52: }
53: }
54:
55: return implode(":", $objArgsArray);
56: //return implode(":", func_get_args());
57: }
58:
59: public function CreateKeyArray($a) {
60: return implode(":", $a);
61: }
62:
63: }