mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-12 14:58:42 +00:00
trying to allow booleans
This commit is contained in:
parent
7c72a40bde
commit
1a54aefaf7
|
|
@ -99,6 +99,10 @@ class RedisCache extends ConnectionAbstract
|
||||||
throw new \InvalidArgumentException();
|
throw new \InvalidArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (\is_bool($value)) {
|
||||||
|
$value = $value ? 'true' : 'false';
|
||||||
|
}
|
||||||
|
|
||||||
if ($expire > 0) {
|
if ($expire > 0) {
|
||||||
$this->con->set($key, $value, $expire);
|
$this->con->set($key, $value, $expire);
|
||||||
}
|
}
|
||||||
|
|
@ -115,10 +119,16 @@ class RedisCache extends ConnectionAbstract
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: pull out
|
||||||
if (!(\is_scalar($value) || $value === null || \is_array($value) || $value instanceof \JsonSerializable || $value instanceof \Serializable)) {
|
if (!(\is_scalar($value) || $value === null || \is_array($value) || $value instanceof \JsonSerializable || $value instanceof \Serializable)) {
|
||||||
throw new \InvalidArgumentException();
|
throw new \InvalidArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: pull out
|
||||||
|
if (\is_bool($value)) {
|
||||||
|
$value = $value ? 'true' : 'false';
|
||||||
|
}
|
||||||
|
|
||||||
if ($expire > 0) {
|
if ($expire > 0) {
|
||||||
return $this->con->setNx($key, $value, $expire);
|
return $this->con->setNx($key, $value, $expire);
|
||||||
}
|
}
|
||||||
|
|
@ -137,6 +147,12 @@ class RedisCache extends ConnectionAbstract
|
||||||
|
|
||||||
$result = $this->con->get($key);
|
$result = $this->con->get($key);
|
||||||
|
|
||||||
|
if ($result === 'true') {
|
||||||
|
$result = true;
|
||||||
|
} elseif ($result === 'false') {
|
||||||
|
$result = false;
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user