1.1.5.3 Cache control

The following methods are available only if the underlying library supports a local cache and cache control.

destroy_cache()
Turns off caching and removed it from memory.

disable_cache()
Temporarily disables use of the cache. New requests are not cached, and the cache is not checked when returning results. Cache contents are not deleted.

enable_cache([timeout=NO_LIMIT, [maxmem=NO_LIMIT]])
Using a cache often greatly improves performance. By default the cache is disabled. Specifying timeout in seconds is used to decide how long to keep cached requests. The maxmem value is in bytes, and is used to set an upper bound on how much memory the cache will use. A value of NO_LIMIT for either indicates unlimited. Subsequent calls to enable_cache() can be used to adjust these parameters.

This and other caching methods are not available if the library and the ldap module were compiled with -DNO_CACHE.

flush_cache()
Deletes the cache's contents, but does not affect it in any other way.

set_cache_options(option)
Changes the caching behaviour. Currently supported options are CACHE_OPT_CACHENOERRS, which suppresses caching of requests that resulted in an error, and CACHE_OPT_CACHEALLERRS, which enables caching of all requests. The default behaviour is not to cache requests that result in errors, except those that result in a SIZELIMIT_EXCEEDED exception.

uncache_entry(dn)
Removes all cached entries that make reference to dn. This should be used, for example, after doing a modify() involving dn.

uncache_request(msgid)
Remove the request indicated by msgid from the cache.