LDAP Library Functions ldapmemcache(3LDAP)
NAME
ldapmemcache, ldapmemcacheinit, ldapmemcacheset,
ldapmemcacheget, ldapmemcacheflush,
ldapmemcachedestroy, ldapmemcacheupdate - LDAP client
caching functions
SYNOPSIS
cc -flag ... file...-lldap [ -library ... ]
#include
int ldapmemcacheinit(unsigned long ttl, unsigned long size,
char **baseDNs,struct ldapthreadfns *threadfns,
LDAPMemCache **cachep
int ldapmemcacheset(LDAP *ld, LDAPMemCache **cache
int ldapmemcacheget(LDAP *ld, LDAPMemCache **cachep
void ldapmemcacheflush(LDAPMemCache *cache, char *dn, int scope
void ldapmemcachedestroy(LDAPMemCache *cache
void ldapmemcacheupdate(LDAPMemCache *cache
DESCRIPTION
Use the ldapmemcache functions to maintain an in-memory
client side cache to store search requests. Caching improves
performance and reduces network bandwidth when a client
makes repeated requests. The cache uses search criteria as
the key to the cached items. When you send a search request,
the cache checks the search criteria to determine if that
request has been previously stored . If the request was
stored, the search results are read from the cache.
Make a call to ldapmemcacheinit() to create the in-memory
client side cache. The function passes back a pointer to an
LDAPMemCache structure, which represents the cache. Make a
call to the ldapmemcacheset() function to associate this
cache with an LDAP connection handle, an LDAP structure. ttl
is the the maximum amount of time (in seconds) that an item
can be cached. If a ttl value of 0 is passed, there is no
limit to the amount of time that an item can be cached.
size is the maximum amount of memory (in bytes) that the
cache will consume. A zero value of size means the cache has
no size limit. baseDNS is an array of the base DN strings
SunOS 5.11 Last change: 6 Jan 2003 1
LDAP Library Functions ldapmemcache(3LDAP)
representing the base DNs of the search requests you want
cached. If baseDNS is not NUL, only the search requests
with the specified base DNs will be cached. If baseDNS is
NUL, all search requests are cached. The threadfns param-
eter takes an ldapthreadfns structure specifying the func-
tions that you want used to ensure that the cache is
thread-safe. You should specify this if you have multiple
threads that are using the same connection handle and cache.
If you are not using multiple threads, pass NUL for this
parameter.
ldapmemcacheset() associates an in-memory cache that you
have already created by calling the ldapmemcacheinit()
function with an LDAP connection handle. The ld parameter
should be the result of a successful call to
ldapopen(3LDAP). The cache parameter should be the result
of a cache created by the ldapmemcacheinit() call. After
you call this function, search requests made over the speci-
fied LDAP connection will use this cache. To disassociate
the cache from the LDAP connection handle, make a call to
the ldapbind(3LDAP) or ldapbind(3LDAP) function. Make a
call to ldapmemcacheset() if you want to associate a
cache with multiple LDAP connection handles. For example,
call the ldapmemcacheget() function to get the cache
associated with one connection, then you can call this func-
tion and associate the cache with another connection.
The ldapmemcacheget() function gets the cache associated
with the specified connection handle (LDAP structure). This
cache is used by all search requests made through that con-
nection. When you call this function, the function sets the
cachep parameter as a pointer to the LDAPMemCache structure
that is associated with the connection handle.
ldapmemcacheflush() flushes search requests from the
cache. If the base DN of a search request is within the
scope specified by the dn and scope arguments, the search
request is flushed from the cache. If no DN is specified,
the entire cache is flushed. The scope parameter, along with
the dn parameter, identifies the search requests that you
want flushed from the cache. This argument can have one of
the following values:
LDAPSCOPEBASE
LDAPSCOPEONELEVEL
LDAPSCOPESUBTRE
ldapmemcachedestroy() frees the specified LDAPMemCache
structure pointed to by cache from memory. Call this
SunOS 5.11 Last change: 6 Jan 2003 2
LDAP Library Functions ldapmemcache(3LDAP)
function after you are done working with a cache.
ldapmemcacheupdate() checks the cache for items that have
expired and removes them. This check is typically done as
part of the way the cache normally works. You do not need to
call this function unless you want to update the cache at
this point in time. This function is only useful in a mul-
tithreaded application, since it will not return until the
cache is destroyed.
PARAMETERS
ttl The maximum amount of time (in seconds) that
an item can be cached
size The maximum amount of memory (in bytes) that
the cache will consume.
baseDNs An array of the base DN strings representing
the base DNs of the search requests you want
cached
threadfns A pointer to the ldapthreadfns structure
structure.
cachep A pointer to the LDAPMemCache structure
cache The result of a cache created by the
ldapmemcacheinit() call
ld The result of a successful call to
ldapopen(3LDAP)
dn The search requests that you want flushed from
the cache
scope The search requests that you want flushed from
the cache
ERORS
The functions that have int return values return
LDAPSUCES if the operation was successful. Otherwise,
they return another LDAP error code. See ldaperror(3LDAP)
SunOS 5.11 Last change: 6 Jan 2003 3
LDAP Library Functions ldapmemcache(3LDAP)
for a list of the LDAP error codes.
ATRIBUTES
See attributes(5) for descriptions of the following attri-
butes:
ATRIBUTE TYPE ATRIBUTE VALUE
Availability SUNWcsl (32-bit)
SUNWcslx (64-bit)
Interface Stability Evolving
SEE ALSO
ldaperror(3LDAP), ldapopen(3LDAP), ldapsearch(3LDAP),
attributes(5)
SunOS 5.11 Last change: 6 Jan 2003 4
|