Added client side caching. (Commited by: Jeff Costlow <j.costlow@f5.com>)

This commit is contained in:
Ralf Haferkamp 2001-05-04 14:38:13 +00:00
parent 0d41df6ff8
commit a2fe43daf9
10 changed files with 126 additions and 55 deletions

View File

@ -80,9 +80,9 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ./src/config.h
CONFIG_CLEAN_FILES =
DIST_COMMON = README AUTHORS Makefile.am Makefile.in TODO acconfig.h \
DIST_COMMON = README AUTHORS INSTALL Makefile.am Makefile.in TODO \
aclocal.m4 config.guess config.sub configure configure.in install-sh \
ltconfig ltmain.sh missing mkinstalldirs src/config.h.in src/stamp-h.in
ltconfig ltmain.sh missing mkinstalldirs
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
@ -106,34 +106,6 @@ config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
src/config.h: src/stamp-h
@if test ! -f $@; then \
rm -f src/stamp-h; \
$(MAKE) src/stamp-h; \
else :; fi
src/stamp-h: $(srcdir)/src/config.h.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES= CONFIG_HEADERS=src/config.h \
$(SHELL) ./config.status
@echo timestamp > src/stamp-h 2> /dev/null
$(srcdir)/src/config.h.in: $(srcdir)/src/stamp-h.in
@if test ! -f $@; then \
rm -f $(srcdir)/src/stamp-h.in; \
$(MAKE) $(srcdir)/src/stamp-h.in; \
else :; fi
$(srcdir)/src/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h
cd $(top_srcdir) && $(AUTOHEADER)
@echo timestamp > $(srcdir)/src/stamp-h.in 2> /dev/null
mostlyclean-hdr:
clean-hdr:
distclean-hdr:
-rm -f src/config.h
maintainer-clean-hdr:
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
@ -269,7 +241,7 @@ distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
cp -pr $$/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
@ -322,33 +294,33 @@ distclean-generic:
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-hdr mostlyclean-tags mostlyclean-generic
mostlyclean-am: mostlyclean-tags mostlyclean-generic
mostlyclean: mostlyclean-recursive
clean-am: clean-hdr clean-tags clean-generic mostlyclean-am
clean-am: clean-tags clean-generic mostlyclean-am
clean: clean-recursive
distclean-am: distclean-hdr distclean-tags distclean-generic clean-am
distclean-am: distclean-tags distclean-generic clean-am
-rm -f libtool
distclean: distclean-recursive
-rm -f config.status
maintainer-clean-am: maintainer-clean-hdr maintainer-clean-tags \
maintainer-clean-generic distclean-am
maintainer-clean-am: maintainer-clean-tags maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-recursive
-rm -f config.status
.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
install-data-recursive uninstall-data-recursive install-exec-recursive \
uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \
all-recursive check-recursive installcheck-recursive info-recursive \
dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \
.PHONY: install-data-recursive uninstall-data-recursive \
install-exec-recursive uninstall-exec-recursive installdirs-recursive \
uninstalldirs-recursive all-recursive check-recursive \
installcheck-recursive info-recursive dvi-recursive \
mostlyclean-recursive distclean-recursive clean-recursive \
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \

View File

@ -35,6 +35,8 @@ LDAPAddRequest::LDAPAddRequest(const LDAPEntry* entry,
LDAPAddRequest::~LDAPAddRequest(){
DEBUG(LDAP_DEBUG_DESTROY, "LDAPAddRequest::~LDAPAddRequest()" << endl);
delete m_entry;
// flush the cache, as the add may affect searches
m_connection->flush_cache();
}
LDAPMessageQueue* LDAPAddRequest::sendRequest(){

View File

@ -36,6 +36,9 @@ LDAPAsynConnection::LDAPAsynConnection(const string& hostname, int port,
LDAPAsynConnection::~LDAPAsynConnection(){
DEBUG(LDAP_DEBUG_DESTROY,
"LDAPAsynConnection::~LDAPAsynConnection()" << endl);
if (cur_session){
ldap_destroy_cache(cur_session);
}
unbind();
//delete m_constr;
}
@ -289,3 +292,26 @@ LDAPAsynConnection* LDAPAsynConnection::referralConnect(
return 0;
}
int LDAPAsynConnection::enableCache(long timeout, long maxmem){
int retval = ldap_enable_cache(cur_session, timeout, maxmem);
if (!retval)
m_cacheEnabled = true;
return retval;
}
void LDAPAsynConnection::disableCache(){
ldap_disable_cache(cur_session);
m_cacheEnabled = false;
}
void LDAPAsynConnection::uncache_entry(string &dn){
if (m_cacheEnabled){
ldap_uncache_entry(cur_session, dn.c_str());
}
}
void LDAPAsynConnection::flush_cache(){
if (m_cacheEnabled){
ldap_flush_cache(cur_session);
}
}

View File

@ -283,6 +283,21 @@ class LDAPAsynConnection{
LDAPUrlList::const_iterator& usedUrl,
const LDAPConstraints* cons) const;
/**
* Turn on caching, maxmem is in MB and timeout is in seconds.
* maxmem can be zero if you want to restrict caching by timeout only.
*/
int enableCache(long timeout, long maxmem);
/// disable caching.
void disableCache();
/// is cacheEnabled?
bool getCacheEnabled() { return m_cacheEnabled;};
/// uncache a specific dn. Used internally by methods that write.
void uncache_entry(string &dn);
/// used to clear the cache. Probably should be used after creating
/// an object that a cached search should find.
void flush_cache();
private :
/**
@ -313,6 +328,11 @@ class LDAPAsynConnection{
*/
int m_port;
protected:
/**
* Is caching enabled?
*/
bool m_cacheEnabled;
};
#endif //LDAP_ASYN_CONNECTION_H

View File

@ -332,3 +332,30 @@ void LDAPConnection::setConstraints(LDAPConstraints* cons){
const LDAPConstraints* LDAPConnection::getConstraints() const{
return LDAPAsynConnection::getConstraints();
}
int LDAPConnection::enableCache(long timeout, long maxmem)
{
return LDAPAsynConnection::enableCache(timeout, maxmem);
}
void LDAPConnection::disableCache()
{
LDAPAsynConnection::disableCache();
}
bool LDAPConnection::getCacheEnabled()
{
return LDAPAsynConnection::getCacheEnabled();
}
void LDAPConnection::uncache_entry(string &dn)
{
LDAPAsynConnection::uncache_entry(dn);
}
void LDAPConnection::flush_cache()
{
LDAPAsynConnection::flush_cache();
}

View File

@ -229,6 +229,22 @@ class LDAPConnection : private LDAPAsynConnection {
void setConstraints(LDAPConstraints *cons);
const LDAPConstraints* getConstraints() const ;
/**
* Turn on caching, maxmem is in MB and timeout is in seconds.
* maxmem can be zero if you want to restrict caching by timeout only.
*/
int enableCache(long timeout, long maxmem);
/// disable caching.
void disableCache();
/// is cacheEnabled?
bool getCacheEnabled();
/// uncache a specific dn. Used internally by methods that write.
void uncache_entry(string &dn);
/// used to clear the cache. Probably should be used after creating
/// an object that a cached search should find.
void flush_cache();
};
#endif //LDAP_CONNECTION_H

View File

@ -33,6 +33,9 @@ LDAPDeleteRequest::LDAPDeleteRequest(const string& dn,
LDAPDeleteRequest::~LDAPDeleteRequest(){
DEBUG(LDAP_DEBUG_DESTROY,
"LDAPDeleteRequest::~LDAPDeleteRequest()" << endl);
// TODO -- flush the entire cache here? or does this invalidate
// cached searches that may have found the deleted entry.
m_connection->uncache_entry(m_dn);
}
LDAPMessageQueue* LDAPDeleteRequest::sendRequest(){

View File

@ -42,6 +42,9 @@ LDAPModDNRequest::LDAPModDNRequest(const string& dn, const string& newRDN,
LDAPModDNRequest::~LDAPModDNRequest(){
DEBUG(LDAP_DEBUG_DESTROY, "LDAPModDNRequest::~LDAPModDNRequest()" << endl);
// flush entries from the cache.
m_connection->uncache_entry(m_dn);
m_connection->uncache_entry(m_newRDN);
}
LDAPMessageQueue* LDAPModDNRequest::sendRequest(){

View File

@ -37,6 +37,8 @@ LDAPModifyRequest::~LDAPModifyRequest(){
DEBUG(LDAP_DEBUG_DESTROY,
"LDAPModifyRequest::~LDAPModifyRequest()" << endl);
delete m_modList;
// flush this entry from cache.
m_connection->uncache_entry(m_dn);
}
LDAPMessageQueue* LDAPModifyRequest::sendRequest(){