~registry/hippo/trunk

« back to all changes in this revision

Viewing changes to lib/cache.php

  • Committer: Jay Pipes
  • Date: 2008-03-31 00:04:28 UTC
  • Revision ID: jay@mysql.com-20080331000428-ke4rj0bzyuk5ps9k
Moved HippoCacheEngine interface into api.php and renamed it to HippoActsAsCacheEngine
to be consistent with other interfaces.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 */
10
10
 
11
11
/**
12
 
 * API for all cache engine adapters.  
13
 
 *
14
 
 * @ingroup Cache
15
 
 */
16
 
interface HippoCacheEngine {
17
 
        /**
18
 
         * All subclasses must implement a get() method to return
19
 
         * a cached item.
20
 
         *
21
 
         * @return      mixed                                                           FALSE if not in cache, otherwise the cached item
22
 
         * @param               key                                                                     Key to the cache item
23
 
         * @param               options                                                 Options to pass to the cache engine (see engine specifics)
24
 
         */
25
 
        public function get($key, $options= array());
26
 
 
27
 
        /**
28
 
         * All subclasses must implement a set() method to 
29
 
         * write the cache item to the cache
30
 
         *
31
 
         * @return      bool                                                            Did the write succeed?
32
 
         * @param               key                                                                     The key for the cache item
33
 
         * @param               value                                                           The value of the cache item
34
 
         */
35
 
        public function set($key, $value);
36
 
 
37
 
        /**
38
 
         * All subclasses must implement a delete() method to 
39
 
         * remove a cache item from the cache
40
 
         *
41
 
         * @return      bool                                                            Did the delete succeed?
42
 
         * @param               key                                                                     The key for the cache item
43
 
         */
44
 
        public function delete($key);
45
 
 
46
 
        /**
47
 
         * All subclasses must implement a purge() method to 
48
 
         * remove blocks of cache items from the cache
49
 
         * 
50
 
         *      optional options argument can contain subclass-specific
51
 
         *      arguments for the purge.
52
 
         *
53
 
         * @return      bool            Did the purge succeed?
54
 
         * @param               options Options to pass the subclass-specific interface
55
 
         */
56
 
        public function purge($options=array());
57
 
}
58
 
 
59
 
/**
60
12
 * Factory class for easy generation of cache engines
61
13
 *
62
14
 * @ingroup Cache
109
61
 *
110
62
 * @ingroup Cache
111
63
 */
112
 
class HippoFileCacheEngine implements HippoCacheEngine {
 
64
class HippoFileCacheEngine implements HippoActsAsCacheEngine {
113
65
 
114
66
        /** The cache directory */
115
67
        public $cache_dir= null;