chiark / gitweb /
A batch of copyright date updates.
[disorder] / lib / cache.h
CommitLineData
460b9539 1/*
2 * This file is part of DisOrder
5aff007d 3 * Copyright (C) 2006-2008 Richard Kettlewell
460b9539 4 *
e7eb3a27 5 * This program is free software: you can redistribute it and/or modify
460b9539 6 * it under the terms of the GNU General Public License as published by
e7eb3a27 7 * the Free Software Foundation, either version 3 of the License, or
460b9539 8 * (at your option) any later version.
e7eb3a27
RK
9 *
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.
14 *
460b9539 15 * You should have received a copy of the GNU General Public License
e7eb3a27 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
460b9539 17 */
0e4472a0 18/** @file lib/cache.h
19 * @brief Object caching
20 *
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.
23 */
460b9539 24
25#ifndef CACHE_H
26#define CACHE_H
27
28/* Defines a cache mapping keys to typed data items */
29
0e4472a0 30/** @brief Type of a cache object */
460b9539 31struct cache_type {
0e4472a0 32 /** @brief Lifetime for objects of this type (seconds) */
33 int lifetime;
460b9539 34};
35
36void 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. */
40
41const void *cache_get(const struct cache_type *type, const char *key);
42/* Get a value from the cache. */
43
44void cache_expire(void);
45/* Expire values from the cache */
46
47void cache_clean(const struct cache_type *type);
48/* Clean all elements of a particular type, or all elements if TYPE=0 */
49
0b7c8909 50size_t cache_count(void);
51/* Return the size of the cache */
52
460b9539 53#endif /* CACHE_H */
54
55/*
56Local Variables:
57c-basic-offset:2
58comment-column:40
59fill-column:79
60indent-tabs-mode:nil
61End:
62*/