diff options
| author | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-09-26 06:28:01 +0000 |
|---|---|---|
| committer | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-09-26 06:28:01 +0000 |
| commit | 4db64caea64450b2cb38161fe961f49162db7a85 (patch) | |
| tree | 35a0b4f5bdb803326dc807e42d516d2c629faee8 /roundcubemail/program | |
| parent | 68e63d65ad9e5764bbd91751dbb7e131121e2e10 (diff) | |
Add method to remove outdated cache entries from sql DB
git-svn-id: https://svn.roundcube.net/trunk@5278 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program')
| -rw-r--r-- | roundcubemail/program/include/rcube_cache.php | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/roundcubemail/program/include/rcube_cache.php b/roundcubemail/program/include/rcube_cache.php index 204eaa570..ee9439101 100644 --- a/roundcubemail/program/include/rcube_cache.php +++ b/roundcubemail/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() |
