summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2011-09-26 06:28:01 +0000
committerthomascube <thomas@roundcube.net>2011-09-26 06:28:01 +0000
commitfeb3783de729a5ac8ca75370ca1e359fb4116160 (patch)
tree27b3d3d6e6708d6a2c7e4c1d53a8bad10efeb250
parent32226f73a638a4782ecd7ba19225503bc276abab (diff)
Add method to remove outdated cache entries from sql DB
-rw-r--r--program/include/rcube_cache.php20
1 files changed, 19 insertions, 1 deletions
diff --git a/program/include/rcube_cache.php b/program/include/rcube_cache.php
index 204eaa570..ee9439101 100644
--- a/program/include/rcube_cache.php
+++ b/program/include/rcube_cache.php
@@ -28,7 +28,7 @@
* @package Cache
* @author Thomas Bruederli <roundcube@gmail.com>
* @author Aleksander Machniak <alec@alec.pl>
- * @version 1.0
+ * @version 1.1
*/
class rcube_cache
{
@@ -188,6 +188,24 @@ class rcube_cache
/**
+ * Remove cache records older than ttl
+ */
+ function expunge()
+ {
+ if ($this->type == 'db' && $this->db) {
+ $this->db->query(
+ "DELETE FROM ".get_table_name('cache').
+ " WHERE user_id = ?".
+ " AND cache_key LIKE ?".
+ " AND " . $this->db->unixtimestamp('created')." < ?",
+ $this->userid,
+ $this->prefix.'.%',
+ time() - $this->ttl);
+ }
+ }
+
+
+ /**
* Writes the cache back to the DB.
*/
function close()