hash_cache.h

00001 /*
00002 Copyright (C) 2003-2004 Douglas Thain and the University of Wisconsin
00003 Copyright (C) 2005- The University of Notre Dame
00004 This software is distributed under the GNU General Public License.
00005 See the file COPYING for details.
00006 */
00007 
00008 #ifndef HASH_CACHE_H
00009 #define HASH_CACHE_H
00010 
00011 #include "hash_table.h"
00012 
00013 /*
00014 A hash_cache is like a hash_table, with one key difference:
00015 Each item is inserted with a lifetime given in seconds.
00016 Once the lifetime has expired, the item is automatically
00017 deleted (using the given cleanup function) and the user
00018 will not see it again.
00019 */
00020 
00021 
00022 typedef void (*hash_cache_cleanup_t) (void *value);
00023 
00024 struct hash_cache *hash_cache_create(int size, hash_func_t func, hash_cache_cleanup_t cleanup);
00025 void hash_cache_delete(struct hash_cache *cache);
00026 
00027 int hash_cache_insert(struct hash_cache *cache, const char *key, void *value, int lifetime);
00028 void *hash_cache_remove(struct hash_cache *cache, const char *key);
00029 void *hash_cache_lookup(struct hash_cache *cache, const char *key);
00030 
00031 void hash_cache_firstkey(struct hash_cache *cache);
00032 int hash_cache_nextkey(struct hash_cache *cache, char **key, void **item);
00033 
00034 #endif