36cde98bd331f208ffeec6525abddec45a463b59
[samba.git] / source3 / include / memcache.h
1 /*
2    Unix SMB/CIFS implementation.
3    In-memory cache
4    Copyright (C) Volker Lendecke 2005-2007
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef __MEMCACHE_H__
21 #define __MEMCACHE_H__
22
23 #include "includes.h"
24
25 struct memcache;
26
27 enum memcache_number {
28         STAT_CACHE,
29         UID_SID_CACHE,
30         SID_UID_CACHE,
31         GID_SID_CACHE,
32         SID_GID_CACHE,
33         GETWD_CACHE,
34         GETPWNAM_CACHE,         /* talloc */
35         MANGLE_HASH2_CACHE
36 };
37
38 struct memcache *memcache_init(TALLOC_CTX *mem_ctx, size_t max_size);
39
40 void memcache_set_global(struct memcache *cache);
41
42 void memcache_add(struct memcache *cache, enum memcache_number n,
43                   DATA_BLOB key, DATA_BLOB value);
44
45 void memcache_add_talloc(struct memcache *cache, enum memcache_number n,
46                          DATA_BLOB key, void *ptr);
47
48 void memcache_delete(struct memcache *cache, enum memcache_number n,
49                      DATA_BLOB key);
50
51 bool memcache_lookup(struct memcache *cache, enum memcache_number n,
52                      DATA_BLOB key, DATA_BLOB *value);
53
54 void *memcache_lookup_talloc(struct memcache *cache, enum memcache_number n,
55                              DATA_BLOB key);
56
57 void memcache_flush(struct memcache *cache, enum memcache_number n);
58
59 #endif