]> git.sur5r.net Git - openldap/blob - doc/man/man5/slapo-pcache.5
032f3250672e2eafc9e52498ceef022c374069b0
[openldap] / doc / man / man5 / slapo-pcache.5
1 .TH SLAPO-PCACHE 5 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" Copyright 1998-2007 The OpenLDAP Foundation, All Rights Reserved.
3 .\" Copying restrictions apply.  See the COPYRIGHT file.
4 .\" Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
5 .\" $OpenLDAP$
6 .SH NAME
7 slapo-pcache \- proxycache overlay to slapd
8 .SH SYNOPSIS
9 ETCDIR/slapd.conf
10 .SH DESCRIPTION
11 The
12 .B pcache
13 overlay to
14 .BR slapd (8)
15 allows caching of LDAP search requests (queries) in a local database.
16 For an incoming query, the
17 proxy cache determines its corresponding \fBtemplate\fP. If the template
18 was specified as cacheable using the \fBproxytemplate\fP directive
19 and the request is contained in a cached request, it is answered from 
20 the proxy cache.
21 Otherwise, the search is performed as usual and cacheable search results 
22 are saved in the cache for use in future queries.
23 .LP
24
25 A template is defined by a filter string and an index identifying a set of
26 attributes. The \fBtemplate string\fP for a query can be obtained by
27 removing assertion values from the RFC 4515 representation of its search
28 filter. A query belongs to a template if its template string and set of
29 projected attributes correspond to a cacheable template.
30 Examples of template strings are \fB(mail=)\fP, \fB(|(sn=)(cn=))\fP,
31 \fB(&(sn=)(givenName=))\fP.
32
33 .LP 
34 The config directives that are specific to the
35 .B proxycache
36 overlay can be prefixed by
37 .BR proxycache\- ,
38 to avoid conflicts with directives specific to the underlying database
39 or to other stacked overlays.  This may be particularly useful for those
40 directives that refer to the backend used for local storage.
41 The following cache specific directives can be used to configure the proxy
42 cache: 
43 .TP
44 .B overlay pcache
45 This directive adds the proxy cache overlay to the current backend. The
46 proxy cache overlay may be used with any backend but is intended for use
47 with the
48 .BR ldap ,
49 .BR meta ,
50 and
51 .BR sql
52 backends.
53 .TP
54 .B proxycache <database> <max_entries> <numattrsets> <entry_limit> <cc_period> 
55 The directive enables proxy caching in the current backend and sets general
56 cache parameters. A <database> backend will be used internally to maintain
57 the cached entries. The chosen database will need to be configured as well,
58 as shown below. Cache replacement is invoked when the cache size grows to 
59 <max_entries> entries and continues till the cache size drops below this size.
60 <numattrsets> should be equal to the number of following \fBproxyattrset\fP
61 directives. Queries are cached only if they correspond to a cacheable template
62 (specified by the \fBproxytemplate\fP directive) and the number of entries
63 returned is less than <entry_limit>. Consistency check is performed every
64 <cc_period> duration (specified in secs). In each cycle queries with expired
65 "time to live(\fBTTL\fP)" are removed. A sample cache configuration is: 
66 .LP
67 .RS
68 proxycache \fBbdb 10000 1 50 100\fP
69 .RE
70
71 .TP
72 .B proxycachequeries <queries>
73 Specify the maximum number of queries to cache. The default is 10000.
74
75 .TP
76 .B proxysavequeries { TRUE | FALSE }
77 Specify whether the cached queries should be saved across restarts
78 of the caching proxy, to provide hot startup of the cache.  Only non-expired
79 queries are reloaded.  The default is FALSE.
80
81 .BR CAVEAT :
82 of course, the configuration of the proxycache must not change
83 across restarts; the pcache overlay does not perform any consistency
84 checks in this sense.
85 In detail, this option should be disabled unless the existing
86 .B proxyattrset
87 and
88 .B proxytemplate
89 directives are not changed neither in order nor in contents.
90 If new sets and templates are added, or if other details of the pcache
91 overlay configuration changed, this feature should not be affected.
92
93 .TP
94 .B proxyattrset <index> <attrs...>
95 Used to associate a set of attributes <attrs..> with an <index>. Each attribute
96 set is associated with an integer from 0 to <numattrsets>-1. These indices are
97 used by the \fBproxytemplate\fP directive to define cacheable templates. 
98 A set of attributes cannot be empty.  A set of attributes can contain the
99 special attributes "*" (all user attributes), "+" (all operational attributes)
100 or both; in the latter case, any other attribute is redundant and should
101 be avoided for clarity.  A set of attributes can contain "1.1" as the only
102 attribute; in this case, only the presence of the entries is cached.
103
104 .TP
105 .B proxytemplate <template_string> <attrset_index> <ttl> [<negttl>]
106 Specifies a cacheable template and "time to live" (in sec) <ttl> of queries 
107 belonging to the template. An optional <negttl> can be used to specify
108 that negative results (i.e., queries that returned zero entries)
109 should also be cached for the specified number of seconds. Negative
110 results are not cached by default.
111
112 .TP
113 .B response-callback { head | tail }
114 Specifies whether the response callback should be placed at the
115 .B tail
116 (the default) or at the 
117 .B head
118 (actually, wherever the stacking sequence would make it appear) 
119 of the callback list.  This affects how the overlay interacts with other
120 overlays, since the proxycache overlay should be executed as early 
121 as possible (and thus configured as late as possible), to get 
122 a chance to return the cached results; however, if executed early
123 at response, it would cache entries that may be later "massaged"
124 by other databases and thus returned \fIafter\fP massaging the first
125 time, and \fIbefore\fP massaging when cached.
126
127 .TP
128 There are some constraints:
129
130 all values must be positive;
131
132 .B <entry_limit>
133 must be less than or equal to
134 .BR <max_entries> ;
135
136 .B <numattrsets>
137 attribute sets SHOULD be defined by using the directive
138 .BR proxyattrset ;
139
140 all attribute sets SHOULD be referenced by (at least) one
141 .B proxytemplate
142 directive; 
143
144 .LP
145 The following adds a template with filter string \fB(&(sn=)(givenName=))\fP 
146 and attributes mail, postaladdress, telephonenumber and a TTL of 1 hour. 
147 .LP
148 .RS
149 .nf
150 proxyattrset \fB0 mail postaladdress telephonenumber\fP
151 proxytemplate \fB(&(sn=)(givenName=)) 0 3600\fP
152 .fi
153 .RE
154
155 .LP
156 Directives for configuring the underlying database must also be given, as
157 shown here:
158 .LP
159 .RS
160 .nf
161 directory /var/tmp/cache
162 cachesize 100
163 .fi
164 .RE
165 .LP
166 Any valid directives for the chosen database type may be used. Indexing
167 should be used as appropriate for the queries being handled. In addition,
168 an equality index on the \fBqueryid\fP attribute should be configured, to
169 assist in the removal of expired query data.
170 .SH CAVEATS
171 Caching data is prone to inconsistencies because updates on the remote server
172 will not be reflected in the response of the cache at least (and at most)
173 for the duration of the
174 .B proxytemplate
175 .BR TTL .
176
177 The remote server should expose the
178 .B objectClass 
179 attribute because the underlying database that actually caches the entries 
180 may need it for optimal local processing of the queries.
181
182 Another potential (and subtle) inconsistency may occur when data is retrieved 
183 with different identities and specific per-identity access control
184 is enforced by the remote server.
185 If data was retrieved with an identity that collected only partial results
186 because of access rules enforcement on the remote server, other users
187 with different access privileges on the remote server will get different
188 results from the remote server and from the cache.
189 If those users have higher access privileges on the remote server, they will 
190 get from the cache only a subset of the results they would get directly 
191 from the remote server; but if they have lower access privileges, they will 
192 get from the cache a superset of the results they would get directly 
193 from the remote server.
194 Either occurrence may or may not be acceptable, based on the security policy
195 of the cache and of the remote server.
196 It is important to note that in this case the proxy is violating the security
197 of the remote server by disclosing to an identity data that was collected 
198 by another identity.
199 For this reason, it is suggested that, when using
200 .BR back-ldap ,
201 proxy caching be used in conjunction with the 
202 .I identity assertion
203 feature of
204 .BR slapd-ldap (5)
205 (see the
206 .B idassert-bind
207 and the
208 .B idassert-authz
209 statements), so that remote server interrogation occurs with a vanilla identity 
210 that has some relatively high
211 .B search
212 and
213 .B read
214 access privileges, and the "real" access control is delegated to the proxy's ACLs.
215 Beware that since only the cached fraction of the real datum is available
216 to the cache, it may not be possible to enforce the same access rules that
217 are defined on the remote server.
218 When security is a concern, cached proxy access must be carefully tailored.
219 .SH FILES
220
221 .TP
222 ETCDIR/slapd.conf
223 default slapd configuration file
224 .SH SEE ALSO
225 .BR slapd.conf (5),
226 .BR slapd\-ldap (5),
227 .BR slapd\-meta (5),
228 .BR slapd\-sql (5),
229 .BR slapd (8).
230 .SH AUTHOR
231 Originally implemented by Apurva Kumar as an extension to back-meta;
232 turned into an overlay by Howard Chu.