[go: up one dir, main page]

File: hash_cache.h

package info (click to toggle)
cctools 9.9-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 44,624 kB
  • sloc: ansic: 192,539; python: 20,827; cpp: 20,199; sh: 11,719; perl: 4,106; xml: 3,688; makefile: 1,224
file content (34 lines) | stat: -rw-r--r-- 1,120 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
Copyright (C) 2003-2004 Douglas Thain and the University of Wisconsin
Copyright (C) 2005- The University of Notre Dame
This software is distributed under the GNU General Public License.
See the file COPYING for details.
*/

#ifndef HASH_CACHE_H
#define HASH_CACHE_H

#include "hash_table.h"

/*
A hash_cache is like a hash_table, with one key difference:
Each item is inserted with a lifetime given in seconds.
Once the lifetime has expired, the item is automatically
deleted (using the given cleanup function) and the user
will not see it again.
*/


typedef void (*hash_cache_cleanup_t) (void *value);

struct hash_cache *hash_cache_create(int size, hash_func_t func, hash_cache_cleanup_t cleanup);
void hash_cache_delete(struct hash_cache *cache);

int hash_cache_insert(struct hash_cache *cache, const char *key, void *value, int lifetime);
void *hash_cache_remove(struct hash_cache *cache, const char *key);
void *hash_cache_lookup(struct hash_cache *cache, const char *key);

void hash_cache_firstkey(struct hash_cache *cache);
int hash_cache_nextkey(struct hash_cache *cache, char **key, void **item);

#endif