2 * This file is part of DisOrder
3 * Copyright (C) 2006-2008 Richard Kettlewell
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * @brief Object caching
21 * There is a single cache for the whole process. Objects of different types
22 * are distinguished. Objects might be thrown out of the cache at any point.
28 /* Defines a cache mapping keys to typed data items */
30 /** @brief Type of a cache object */
32 /** @brief Lifetime for objects of this type (seconds) */
36 void cache_put(const struct cache_type *type,
37 const char *key, const void *value);
38 /* Inserts KEY into the cache with value VALUE. If KEY is already
39 * present it is overwritten. */
41 const void *cache_get(const struct cache_type *type, const char *key);
42 /* Get a value from the cache. */
44 void cache_expire(void);
45 /* Expire values from the cache */
47 void cache_clean(const struct cache_type *type);
48 /* Clean all elements of a particular type, or all elements if TYPE=0 */
50 size_t cache_count(void);
51 /* Return the size of the cache */