1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2000-2012 Jeffrey Stedfast
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2.1
8 * of the License, or (at your option) any later version.
10 * This library 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 GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
27 #include <sys/types.h>
29 #include <util/list.h>
33 typedef struct _Cache Cache;
41 typedef gboolean (*CacheNodeExpireFunc) (Cache *cache, CacheNode *node);
42 typedef void (*CacheNodeFreeFunc) (CacheNode *node);
49 GHashTable *node_hash;
50 CacheNodeExpireFunc expire;
51 CacheNodeFreeFunc free_node;
55 G_GNUC_INTERNAL Cache *cache_new (CacheNodeExpireFunc expire, CacheNodeFreeFunc free_node,
56 size_t bucket_size, size_t max_cache_size);
58 G_GNUC_INTERNAL void cache_free (Cache *cache);
60 G_GNUC_INTERNAL CacheNode *cache_node_insert (Cache *cache, const char *key);
61 G_GNUC_INTERNAL CacheNode *cache_node_lookup (Cache *cache, const char *key, gboolean use);
63 G_GNUC_INTERNAL void cache_expire_unused (Cache *cache);
64 G_GNUC_INTERNAL void cache_node_expire (CacheNode *node);
68 #endif /* __CACHE_H__ */