Skip to content

Commit

Permalink
Cope with missing Memcache.
Browse files Browse the repository at this point in the history
  • Loading branch information
dracos committed Dec 18, 2023
1 parent fd6b634 commit 4ffc97d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions classes/Memcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ public function __construct() {
if (class_exists('\Memcached')) {
self::$memcache = new \Memcached;
self::$memcache->addServer(OPTION_TWFY_MEMCACHED_HOST, OPTION_TWFY_MEMCACHED_PORT);
} else {
} elseif (class_exists('\Memcache')) {
self::$memcache = new \Memcache;
self::$memcache->connect(OPTION_TWFY_MEMCACHED_HOST, OPTION_TWFY_MEMCACHED_PORT);
}
}
}

public function set($key, $value, $timeout = 3600) {
if (!self::$memcache) {
return;
}
if (class_exists('\Memcached')) {
self::$memcache->set(OPTION_TWFY_DB_NAME.':'.$key, $value, $timeout);
} else {
Expand All @@ -37,7 +40,7 @@ public function get($key) {
$was_found = false;
if (class_exists('\Memcached')) {
$value = self::$memcache->get(OPTION_TWFY_DB_NAME.':'.$key, null, $was_found);
} else {
} elseif (class_exists('\Memcache')) {
$value = self::$memcache->get(OPTION_TWFY_DB_NAME.':'.$key, $was_found);
}
if ($was_found === false) {
Expand Down

0 comments on commit 4ffc97d

Please sign in to comment.