mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-21 22:08:41 +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();
|
||||
}
|
||||
|
||||
if (\is_bool($value)) {
|
||||
$value = $value ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($expire > 0) {
|
||||
$this->con->set($key, $value, $expire);
|
||||
}
|
||||
|
|
@ -115,10 +119,16 @@ class RedisCache extends ConnectionAbstract
|
|||
return false;
|
||||
}
|
||||
|
||||
// todo: pull out
|
||||
if (!(\is_scalar($value) || $value === null || \is_array($value) || $value instanceof \JsonSerializable || $value instanceof \Serializable)) {
|
||||
throw new \InvalidArgumentException();
|
||||
}
|
||||
|
||||
// todo: pull out
|
||||
if (\is_bool($value)) {
|
||||
$value = $value ? 'true' : 'false';
|
||||
}
|
||||
|
||||
if ($expire > 0) {
|
||||
return $this->con->setNx($key, $value, $expire);
|
||||
}
|
||||
|
|
@ -137,6 +147,12 @@ class RedisCache extends ConnectionAbstract
|
|||
|
||||
$result = $this->con->get($key);
|
||||
|
||||
if ($result === 'true') {
|
||||
$result = true;
|
||||
} elseif ($result === 'false') {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user