|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--netscape.ldap.LDAPCache
LDAPCache
represents an in-memory cache that you can use
to reduce the number of search requests sent to the LDAP server.
Each item in the cache represents a search request and its results. Each item is uniquely identified by the search criteria, which includes:
After a search request is cached, the results of any subsequent search requests using the same criteria are read from the cache. Note that if any part of the criteria differs (for example, if a different DN is used when binding to the server or if a different set of attributes to be returned is specified), the search request is sent to the server.
When you create the cache, you specify the maximum amount of time that an item can be kept in the cache. When an item's age exceeds that time limit, the item is removed from the cache.
The cache also has a maximum size that you specify when creating the cache. If adding a new item exceeds the maximum size of the cache, the first entries in the cache are removed to make enough space for the new item.
Finally, when creating the cache, you can specify a list
of the base DNs in search requests that you want to cache.
For example, if you specify o=Airius.com
as
a base DN to cache, your client caches search requests
where the base DN is o=Airius.com
.
To specify that you want to use a cache for a particular
LDAP session, call the setCache
method of
the LDAPConnection
object that you are
working with.
All clones of an LDAPConnection
object share
the same LDAPCache
object.
Note that search requests that return referrals are not cached.
The LDAPCache
class includes methods for
getting statistics (such as hit rates) from the cache and
for flushing entries from the cache.
LDAPConnection.setCache(netscape.ldap.LDAPCache)
,
LDAPConnection.getCache()
Field Summary | |
static java.lang.String |
DELIM
Delimiter used internally when creating keys for the cache. |
Constructor Summary | |
LDAPCache(long ttl,
long size)
Constructs a new LDAPCache object, using the
specified maximum size of the cache (in bytes) and the maximum
age of cached items (in seconds). |
|
LDAPCache(long ttl,
long size,
java.lang.String[] dns)
Constructs a new LDAPCache object, using the
specified maximum size of the cache (in bytes), and the maximum
age of cached items (in seconds), and an array of the base DNs
of searches that you want to cache. |
Method Summary | |
boolean |
flushEntries(java.lang.String dn,
int scope)
Flush the entries identified by DN and scope from the cache. |
long |
getAvailableSize()
Gets the amount of available space (in bytes) left in the cache. |
java.lang.String[] |
getBaseDNs()
Gets the array of base DNs of searches to be cached. |
int |
getNumEntries()
Gets the number of entries being cached. |
long |
getNumFlushes()
Gets the total number of entries that are flushed when timer expires and flushEntries is called. |
long |
getNumHits()
Gets the total number of requests which successfully found and retrieved an item from the cache. |
long |
getNumMisses()
Gets the total number of requests which failed to find and retrieve an item from the cache. |
long |
getSize()
Gets the maximum size of the cache (in bytes). |
long |
getTimeToLive()
Gets the maximum age allowed for cached items (in seconds). |
long |
getTotalOperations()
Gets the total number of requests for retrieving items from the cache. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final java.lang.String DELIM
Constructor Detail |
public LDAPCache(long ttl, long size)
LDAPCache
object, using the
specified maximum size of the cache (in bytes) and the maximum
age of cached items (in seconds). When items in the cache
exceed this age, they are removed from the cache.
ttl
- the maximum amount of time that an item can be cached
(in seconds)size
- the maximum size of the cache (in bytes)public LDAPCache(long ttl, long size, java.lang.String[] dns)
LDAPCache
object, using the
specified maximum size of the cache (in bytes), and the maximum
age of cached items (in seconds), and an array of the base DNs
of searches that you want to cache. (For example,
if the array of base DNs includes o=Airius.com
,
the cache stores search results if the base DN in the search
request is o=Airius.com
.)
ttl
- the maximum amount of time that an item can be cached
(in seconds)size
- the maximum size of the cache (in bytes)dns
- the list of base DNs of searches that you want to cache.Method Detail |
public long getSize()
public long getTimeToLive()
public java.lang.String[] getBaseDNs()
public boolean flushEntries(java.lang.String dn, int scope)
dn
- the distinguished name (or base DN) of the entries
to be removed from the cache. Use this parameter in conjunction
with scope
to identify the entries that you want
removed from the cache. If this parameter is null
,
the entire cache is flushed.scope
- the scope identifying the entries that you want
removed from the cache. The value of this parameter can be
one of the following:
LDAPv2.SCOPE_BASE
(to remove the entry identified
by dn
)
LDAPv2.SCOPE_ONE
(to remove the entries that
have dn
as their parent entry)
LDAPv2.SCOPE_SUB
(to remove the entries in the
subtree under dn
in the directory)
true
if the entry is removed from the cache;
false
if the entry is not removed.public long getAvailableSize()
public long getTotalOperations()
public long getNumMisses()
public long getNumHits()
public long getNumFlushes()
flushEntries
is called.
public int getNumEntries()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |