4 +-----------------------------------------------------------------------+
5 | program/include/cache.inc |
7 | This file is part of the RoundCube Webmail client |
8 | Copyright (C) 2005, RoundCube Dev, - Switzerland |
9 | Licensed under the GNU GPL |
12 | Provide access to the application cache |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: cache.inc 88 2005-12-03 16:54:12Z roundcube $
23 function rcube_read_cache($key)
25 global $DB, $CACHE_KEYS;
28 $sql_result = $DB->query("SELECT cache_id, data
29 FROM ".get_table_name('cache')."
36 if ($sql_arr = $DB->fetch_assoc($sql_result))
38 $data = $sql_arr['data'];
39 $CACHE_KEYS[$key] = $sql_arr['cache_id'];
48 function rcube_write_cache($key, $data, $session_cache=FALSE)
50 global $DB, $CACHE_KEYS, $sess_id;
52 // check if we already have a cache entry for this key
53 if (!isset($CACHE_KEYS[$key]))
55 $sql_result = $DB->query("SELECT cache_id
56 FROM ".get_table_name('cache')."
62 if ($sql_arr = $DB->fetch_assoc($sql_result))
63 $CACHE_KEYS[$key] = $sql_arr['cache_id'];
65 $CACHE_KEYS[$key] = FALSE;
68 // update existing cache record
69 if ($CACHE_KEYS[$key])
71 $DB->query("UPDATE ".get_table_name('cache')."
80 // add new cache record
83 $DB->query("INSERT INTO ".get_table_name('cache')."
84 (created, user_id, session_id, cache_key, data)
85 VALUES (now(), ?, ?, ?, ?)",
87 $session_cache ? $sess_id : 'NULL',
94 function rcube_clear_cache($key)
98 $DB->query("DELETE FROM ".get_table_name('cache')."
101 $_SESSION['user_id'],