fa72a4aa466f35bbad9e4f5d6a7e94a9708bb0d0
[samba.git] / source3 / lib / gencache.h
1 /*
2  * Unix SMB/CIFS implementation.
3  *
4  * Generic, persistent and shared between processes cache mechanism for use
5  * by various parts of the Samba code
6  *
7  * Copyright (C) Rafal Szczesniak    2002
8  * Copyright (C) Volker Lendecke     2009
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  */
23
24 #ifndef __LIB_GENCACHE_H__
25 #define __LIB_GENCACHE_H__
26
27 #include "replace.h"
28 #include "system/time.h"
29 #include "lib/util/data_blob.h"
30
31 bool gencache_set(const char *keystr, const char *value, time_t timeout);
32 bool gencache_del(const char *keystr);
33 bool gencache_get(const char *keystr, TALLOC_CTX *mem_ctx, char **value,
34                   time_t *ptimeout);
35 bool gencache_parse(const char *keystr,
36                     void (*parser)(time_t timeout, DATA_BLOB blob,
37                                    void *private_data),
38                     void *private_data);
39 bool gencache_get_data_blob(const char *keystr, TALLOC_CTX *mem_ctx,
40                             DATA_BLOB *blob,
41                             time_t *timeout, bool *was_expired);
42 bool gencache_stabilize(void);
43 bool gencache_set_data_blob(const char *keystr, DATA_BLOB blob,
44                             time_t timeout);
45 void gencache_iterate_blobs(void (*fn)(const char *key, DATA_BLOB value,
46                                        time_t timeout, void *private_data),
47                             void *private_data, const char *pattern);
48 void gencache_iterate(void (*fn)(const char* key, const char *value,
49                                  time_t timeout, void* dptr),
50                       void* data, const char* keystr_pattern);
51
52 #endif