root/trunk/src/main/php/net/stubbles/util/cache/stubCacheContainer.php

Revision 1230, 2.7 kB (checked in by mikey, 4 months ago)

continued refactoring #119: replaced package dots in net::stubbles::util

Line 
1 <?php
2 /**
3  * Interface for cache containers.
4  *
5  * @author      Frank Kleine <mikey@stubbles.net>
6  * @package     stubbles
7  * @subpackage  util_cache
8  */
9 stubClassLoader::load('net::stubbles::util::cache::stubCacheStrategy');
10 /**
11  * Interface for cache containers.
12  *
13  * @package     stubbles
14  * @subpackage  util_cache
15  */
16 interface stubCacheContainer extends stubObject, stubSerializable
17 {
18     /**
19      * sets the id of the container
20      *
21      * @param  string  $id
22      */
23     public function setId($id);
24
25     /**
26      * returns the id of the container
27      *
28      * @return  string
29      */
30     public function getId();
31
32     /**
33      * sets the strategy the container should use
34      *
35      * @param  stubCacheStrategy  $strategy
36      */
37     public function setStrategy(stubCacheStrategy $strategy);
38
39     /**
40      * puts date into the cache
41      *
42      * Returns amount of cached bytes or false if caching failed.
43      *
44      * @param   string    $key   key under which the data should be stored
45      * @param   string    $data  data that should be cached
46      * @return  int|bool
47      */
48     public function put($key, $data);
49
50     /**
51      * checks whether data is cached under the given key
52      *
53      * @param   string  $key
54      * @return  bool
55      */
56     public function has($key);
57
58     /**
59      * checks whether cache data is expired
60      *
61      * @param   string  $key   key under which the data is stored
62      * @return  bool
63      */
64     public function isExpired($key);
65
66     /**
67      * fetches data from the cache
68      *
69      * Returns null if no data is cached under the given key.
70      *
71      * @param   string  $key
72      * @return  string
73      */
74     public function get($key);
75
76     /**
77      * returns the time in seconds how long the data associated with $key is cached
78      *
79      * @param   string  $key
80      * @return  int
81      */
82     public function getLifeTime($key);
83
84     /**
85      * returns the timestamp when data associated with $key is cached
86      *
87      * @param   string  $key
88      * @return  int
89      */
90     public function getStoreTime($key);
91
92     /**
93      * returns the allocated space of the data associated with $key in bytes
94      *
95      * @param   string  $key
96      * @return  int
97      */
98     public function getSize($key);
99
100     /**
101      * returns the amount of bytes the cache data requires
102      *
103      * @return  int
104      */
105     public function getUsedSpace();
106
107     /**
108      * returns a list of all keys that are stored in the cache
109      *
110      * @return  array<string>
111      */
112     public function getKeys();
113
114     /**
115      * returns the unix timestamp of the last run of the garbage collection
116      *
117      * @return  int
118      */
119     public function lastGcRun();
120
121     /**
122      * runs the garbage collection
123      */
124     public function gc();
125 }
126 ?>
Note: See TracBrowser for help on using the browser.