From cde30c510dfbf07af81879b3d3b225b810a079eb Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Wed, 22 Sep 2010 21:33:02 +0200 Subject: [PATCH] Fix schema caching. --- framework/Ldap/lib/Horde/Ldap.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/framework/Ldap/lib/Horde/Ldap.php b/framework/Ldap/lib/Horde/Ldap.php index 93d6136c7..ec2f5b042 100644 --- a/framework/Ldap/lib/Horde/Ldap.php +++ b/framework/Ldap/lib/Horde/Ldap.php @@ -62,7 +62,8 @@ class Horde_Ldap 'min_backoff' => 1, 'current_backoff' => 1, 'max_backoff' => 32, - 'cache' => null); + 'cache' => false, + 'cachettl' => 3600); /** * List of hosts we try to establish a connection to. @@ -1279,7 +1280,10 @@ class Horde_Ldap * schema object. */ $key = 'Horde_Ldap_Schema_' . md5(serialize(array($this->_config['hostspec'], $this->_config['port'], $dn))); if (!$this->_schema && $this->_config['cache']) { - $this->_schema = $this->_config['cache']->get($key); + $schema = $this->_config['cache']->get($key, $this->_config['cachettl']); + if ($schema) { + $this->_schema = @unserialize($schema); + } } /* Fetch schema, if not tried before and no cached version available. @@ -1294,7 +1298,7 @@ class Horde_Ldap /* If schema caching is active, advise the cache to store the * schema. */ if ($this->_config['cache']) { - $this->_config['cache']->set($key, $this->_schema); + $this->_config['cache']->set($key, serialize($this->_schema), $this->_config['cachettl']); } } -- 2.11.0