aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_datacache_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2009-07-25 21:31:57 +0000
committerChristian Grothoff <christian@grothoff.org>2009-07-25 21:31:57 +0000
commited5a799335a4746725430551b5ad1b0b6f2a40f0 (patch)
tree4c2f9fc5f78067a293646f53a4ce44a1f8eaa86f /src/include/gnunet_datacache_lib.h
parentb37616bc95ff84845cecfdaca315fe21fa3ac211 (diff)
downloadgnunet-ed5a799335a4746725430551b5ad1b0b6f2a40f0.tar.gz
gnunet-ed5a799335a4746725430551b5ad1b0b6f2a40f0.zip
dcl
Diffstat (limited to 'src/include/gnunet_datacache_lib.h')
-rw-r--r--src/include/gnunet_datacache_lib.h130
1 files changed, 130 insertions, 0 deletions
diff --git a/src/include/gnunet_datacache_lib.h b/src/include/gnunet_datacache_lib.h
new file mode 100644
index 000000000..64d1d4883
--- /dev/null
+++ b/src/include/gnunet_datacache_lib.h
@@ -0,0 +1,130 @@
1/*
2 This file is part of GNUnet
3 (C) 2006, 2009 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file include/gnunet_datacache_lib.h
23 * @brief datacache is a simple, transient hash table
24 * of bounded size with content expiration.
25 * In contrast to the sqstore there is
26 * no prioritization, deletion or iteration.
27 * All of the data is discarded when the peer shuts down!
28 * @author Christian Grothoff
29 */
30
31#ifndef GNUNET_DATACACHE_LIB_H
32#define GNUNET_DATACACHE_LIB_H
33
34#include "gnunet_util_lib.h"
35
36#ifdef __cplusplus
37extern "C"
38{
39#if 0 /* keep Emacsens' auto-indent happy */
40}
41#endif
42#endif
43
44
45/**
46 * Handle to the cache.
47 */
48struct GNUNET_DATACACHE_Handle;
49
50
51/**
52 * Create a data cache.
53 *
54 * @param cfg configuration to use
55 * @param section section in the configuration that contains our options
56 * @return handle to use to access the service
57 */
58struct GNUNET_DATACACHE_Handle *
59GNUNET_DATACACHE_create (struct GNUNET_CONFIGURATION_Handle *cfg,
60 const char *section);
61
62
63/**
64 * Destroy a data cache (and free associated resources).
65 *
66 * @param h handle to the datastore
67 */
68void GNUNET_DATACACHE_destroy (struct GNUNET_DATACACHE_Handle *h);
69
70
71/**
72 * An iterator over a set of items stored in the datacache.
73 *
74 * @param cls closure
75 * @param key key for the content
76 * @param size number of bytes in data
77 * @param data content stored
78 * @param type type of the content
79 */
80typedef void (*GNUNET_DATACACHE_Iterator) (void *cls,
81 const GNUNET_HashCode * key,
82 uint32_t size,
83 const char *data,
84 uint32_t type);
85
86
87/**
88 * Store an item in the datastore.
89 *
90 * @param key key to store data under
91 * @param size number of bytes in data
92 * @param data data to store
93 * @param type type of the value
94 * @param discard_time when to discard the value in any case
95 * @return GNUNET_OK on success, GNUNET_SYSERR on error (full, etc.)
96 */
97int
98GNUNET_DATACACHE_put (const GNUNET_HashCode * key,
99 uint32_t size,
100 const char *data,
101 unsigned int type,
102 struct GNUNET_TIME_Absolute discard_time);
103
104
105/**
106 * Iterate over the results for a particular key
107 * in the datastore.
108 *
109 * @param key what to look up
110 * @param type entries of which type are relevant?
111 * @param iter maybe NULL (to just count)
112 * @param iter_cls closure for iter
113 * @return the number of results found
114 */
115unsigned int
116GNUNET_DATACACHE_get (const GNUNET_HashCode * key,
117 unsigned int type,
118 GNUNET_DATACACHE_Iterator iter,
119 void *iter_cls);
120
121
122#if 0 /* keep Emacsens' auto-indent happy */
123{
124#endif
125#ifdef __cplusplus
126}
127#endif
128
129/* end of gnunet_datacache_lib.h */
130#endif