source: branches/samba-3.2.x/docs-xml/Samba3-Developers-Guide/gencache.xml@ 231

Last change on this file since 231 was 203, checked in by Herwig Bauernfeind, 17 years ago

Missing 3.2.2 client and HOWTO files

File size: 3.9 KB
Line 
1<?xml version="1.0" encoding="iso-8859-1"?>
2<!DOCTYPE chapter PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
3<chapter id="gencache">
4<chapterinfo>
5 <author>
6 <firstname>Rafal</firstname><surname>Szczesniak</surname>
7 </author>
8 <pubdate>April 2003</pubdate>
9</chapterinfo>
10
11<title>General cache mechanism and API</title>
12
13<sect1>
14<title>Abstract</title>
15<para>
16General cache (gencache) was designed to combine various kinds of caching
17mechanisms into one, defined by a simple API. This way, anyone can use it
18to create their own caching layer on top of gencache. An example of
19such approach is the netbios name cache.
20</para>
21</sect1>
22
23<sect1>
24<title>The mechanism</title>
25<para>
26Gencache utilises <emphasise>tdb</emphasise> database, like many other
27parts of Samba. As its origins are in Berkeley DB implementation, it
28uses key/value pairs stored in binary file. The values gencache
29operates on are string-based, however. This makes very easy to use it
30in command line environment eg. to quickly take a look at what's in
31the cache or set some value.
32</para>
33
34<para>
35All the data is stored in <filename>gencache.tdb</filename>
36file. Records put there are in key/value format as mentioned below,
37but as it's a cache, the timeout plays also important role and has a
38special place in the key/value pair, as well as API.
39</para>
40</sect1>
41
42
43<sect1>
44<title>The data structure</title>
45<para>
46The record stored in <filename>gencache.tdb</filename> file consists
47of the key, the value and the expiration timeout. While the first part
48is stored completely independent from the others, the last two are
49kept together. The form the record has is:
50</para>
51
52<para><programlisting>
53key: &lt;string&gt;
54value: &lt;12-digit timeout&gt;/&lt;string&gt;
55</programlisting></para>
56
57<para>The timeout part is the ASCII representation of
58<emphasis>time_t</emphasis> value of the time when the cache entry
59expires. Obviously the API, the programmer is provided with, hides this detail,
60so that you don't have to care about checking it. Simply watch
61carefully the return status of the function.
62</para>
63</sect1>
64
65<sect1>
66<title>The API</title>
67
68<para><programlisting>
69BOOL gencache_init()
70</programlisting></para>