aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Memcache
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Memcache')
-rw-r--r--lib/private/Memcache/Redis.php24
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/private/Memcache/Redis.php b/lib/private/Memcache/Redis.php
index 74d8da187fe..63180dd8066 100644
--- a/lib/private/Memcache/Redis.php
+++ b/lib/private/Memcache/Redis.php
@@ -54,8 +54,12 @@ class Redis extends Cache implements IMemcacheTTL {
return $this->prefix;
}
+ private function logEnabled(): bool {
+ return $this->logFile !== '' && is_writable(dirname($this->logFile)) && (!file_exists($this->logFile) || is_writable($this->logFile));
+ }
+
public function get($key) {
- if ($this->logFile !== '' && is_writable($this->logFile)) {
+ if ($this->logEnabled()) {
file_put_contents(
$this->logFile,
$this->getNameSpace() . '::get::' . $key . "\n",
@@ -72,7 +76,7 @@ class Redis extends Cache implements IMemcacheTTL {
}
public function set($key, $value, $ttl = 0) {
- if ($this->logFile !== '' && is_writable($this->logFile)) {
+ if ($this->logEnabled()) {
file_put_contents(
$this->logFile,
$this->getNameSpace() . '::set::' . $key . '::' . $ttl . '::' . json_encode($value) . "\n",
@@ -88,7 +92,7 @@ class Redis extends Cache implements IMemcacheTTL {
}
public function hasKey($key) {
- if ($this->logFile !== '' && is_writable($this->logFile)) {
+ if ($this->logEnabled()) {
file_put_contents(
$this->logFile,
$this->getNameSpace() . '::hasKey::' . $key . "\n",
@@ -100,7 +104,7 @@ class Redis extends Cache implements IMemcacheTTL {
}
public function remove($key) {
- if ($this->logFile !== '' && is_writable($this->logFile)) {
+ if ($this->logEnabled()) {
file_put_contents(
$this->logFile,
$this->getNameSpace() . '::remove::' . $key . "\n",
@@ -116,7 +120,7 @@ class Redis extends Cache implements IMemcacheTTL {
}
public function clear($prefix = '') {
- if ($this->logFile !== '' && is_writable($this->logFile)) {
+ if ($this->logEnabled()) {
file_put_contents(
$this->logFile,
$this->getNameSpace() . '::clear::' . $prefix . "\n",
@@ -149,7 +153,7 @@ class Redis extends Cache implements IMemcacheTTL {
if ($ttl !== 0 && is_int($ttl)) {
$args['ex'] = $ttl;
}
- if ($this->logFile !== '' && is_writable($this->logFile)) {
+ if ($this->logEnabled()) {
file_put_contents(
$this->logFile,
$this->getNameSpace() . '::add::' . $key . '::' . $value . "\n",
@@ -169,7 +173,7 @@ class Redis extends Cache implements IMemcacheTTL {
* @return int | bool
*/
public function inc($key, $step = 1) {
- if ($this->logFile !== '' && is_writable($this->logFile)) {
+ if ($this->logEnabled()) {
file_put_contents(
$this->logFile,
$this->getNameSpace() . '::inc::' . $key . "\n",
@@ -188,7 +192,7 @@ class Redis extends Cache implements IMemcacheTTL {
* @return int | bool
*/
public function dec($key, $step = 1) {
- if ($this->logFile !== '' && is_writable($this->logFile)) {
+ if ($this->logEnabled()) {
file_put_contents(
$this->logFile,
$this->getNameSpace() . '::dec::' . $key . "\n",
@@ -211,7 +215,7 @@ class Redis extends Cache implements IMemcacheTTL {
* @return bool
*/
public function cas($key, $old, $new) {
- if ($this->logFile !== '' && is_writable($this->logFile)) {
+ if ($this->logEnabled()) {
file_put_contents(
$this->logFile,
$this->getNameSpace() . '::cas::' . $key . "\n",
@@ -241,7 +245,7 @@ class Redis extends Cache implements IMemcacheTTL {
* @return bool
*/
public function cad($key, $old) {
- if ($this->logFile !== '' && is_writable($this->logFile)) {
+ if ($this->logEnabled()) {
file_put_contents(
$this->logFile,
$this->getNameSpace() . '::cad::' . $key . "\n",