summaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorMathias <mathias@mediamixx.de>2019-05-24 12:08:44 +0200
committerGitHub <noreply@github.com>2019-05-24 12:08:44 +0200
commit6d8d3b67d89c5d6f8d36fb22e13c3da89cb44faf (patch)
treeef39cea687dd3a76205969054eb6c6ea00ef9d30 /demo
parentc9f0de05f41b9e52798b268ab1e625fac3b8578c (diff)
downloadsmarty-6d8d3b67d89c5d6f8d36fb22e13c3da89cb44faf.tar.gz
smarty-6d8d3b67d89c5d6f8d36fb22e13c3da89cb44faf.tar.bz2
smarty-6d8d3b67d89c5d6f8d36fb22e13c3da89cb44faf.zip
Changed read and write methods for compatibility with class memcached
The methods of the memcached class have different parameters than the memcache class.
Diffstat (limited to 'demo')
-rw-r--r--demo/plugins/cacheresource.memcache.php22
1 files changed, 10 insertions, 12 deletions
diff --git a/demo/plugins/cacheresource.memcache.php b/demo/plugins/cacheresource.memcache.php
index 9c8855c3..71fe9d3f 100644
--- a/demo/plugins/cacheresource.memcache.php
+++ b/demo/plugins/cacheresource.memcache.php
@@ -42,18 +42,12 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
*/
protected function read(array $keys)
{
- $_keys = $lookup = array();
- foreach ($keys as $k) {
- $_k = sha1($k);
- $_keys[] = $_k;
- $lookup[ $_k ] = $k;
- }
- $_res = array();
- $res = $this->memcache->get($_keys);
- foreach ($res as $k => $v) {
- $_res[ $lookup[ $k ] ] = $v;
+ $res = array();
+ foreach ($keys as $key) {
+ $k = sha1($key);
+ $res[$key] = $this->memcache->get($k);
}
- return $_res;
+ return $res;
}
/**
@@ -68,7 +62,11 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
{
foreach ($keys as $k => $v) {
$k = sha1($k);
- $this->memcache->set($k, $v, 0, $expire);
+ if (class_exists('Memcached')) {
+ $this->memcache->set($k, $v, $expire);
+ } else {
+ $this->memcache->set($k, $v, 0, $expire);
+ }
}
return true;
}