cctools
hash_cache.h
1
/*
2
Copyright (C) 2003-2004 Douglas Thain and the University of Wisconsin
3
Copyright (C) 2022 The University of Notre Dame
4
This software is distributed under the GNU General Public License.
5
See the file COPYING for details.
6
*/
7
8
#ifndef HASH_CACHE_H
9
#define HASH_CACHE_H
10
11
#include "
hash_table.h
"
12
13
/*
14
A hash_cache is like a hash_table, with one key difference:
15
Each item is inserted with a lifetime given in seconds.
16
Once the lifetime has expired, the item is automatically
17
deleted (using the given cleanup function) and the user
18
will not see it again.
19
*/
20
21
22
typedef
void (*hash_cache_cleanup_t) (
void
*value);
23
24
struct
hash_cache *hash_cache_create(
int
size,
hash_func_t
func, hash_cache_cleanup_t cleanup);
25
void
hash_cache_delete(
struct
hash_cache *cache);
26
27
int
hash_cache_insert(
struct
hash_cache *cache,
const
char
*key,
void
*value,
int
lifetime);
28
void
*hash_cache_remove(
struct
hash_cache *cache,
const
char
*key);
29
void
*hash_cache_lookup(
struct
hash_cache *cache,
const
char
*key);
30
31
void
hash_cache_firstkey(
struct
hash_cache *cache);
32
int
hash_cache_nextkey(
struct
hash_cache *cache,
char
**key,
void
**item);
33
34
#endif
hash_func_t
unsigned(* hash_func_t)(const char *key)
The type signature for a hash function given to hash_table_create.
Definition:
hash_table.h:41
hash_table.h
dttools
src
hash_cache.h
Generated by
1.8.17