[CORE][Cache] Workaround to redis not allowing empty lists
This commit is contained in:
parent
06ece5b72e
commit
cdf1d67d0f
@ -242,7 +242,7 @@ abstract class Cache
|
|||||||
public static function getList(string $key, callable $calculate, string $pool = 'default', ?int $max_count = null, ?int $left = null, ?int $right = null, float $beta = 1.0): array
|
public static function getList(string $key, callable $calculate, string $pool = 'default', ?int $max_count = null, ?int $left = null, ?int $right = null, float $beta = 1.0): array
|
||||||
{
|
{
|
||||||
if (isset(self::$redis[$pool])) {
|
if (isset(self::$redis[$pool])) {
|
||||||
return self::redisMaybeRecompute(
|
$result = self::redisMaybeRecompute(
|
||||||
$key,
|
$key,
|
||||||
recompute: /**
|
recompute: /**
|
||||||
* Caculate and trim the list to the correct size
|
* Caculate and trim the list to the correct size
|
||||||
@ -268,6 +268,7 @@ abstract class Cache
|
|||||||
pool: $pool,
|
pool: $pool,
|
||||||
beta: $beta,
|
beta: $beta,
|
||||||
);
|
);
|
||||||
|
return empty($result) ? [] : $result; // TODO may be wrong? not sure
|
||||||
} else {
|
} else {
|
||||||
return self::get(
|
return self::get(
|
||||||
$key,
|
$key,
|
||||||
@ -295,7 +296,7 @@ abstract class Cache
|
|||||||
{
|
{
|
||||||
if (isset(self::$redis[$pool])) {
|
if (isset(self::$redis[$pool])) {
|
||||||
if (empty($value)) {
|
if (empty($value)) {
|
||||||
self::$redis[$pool]->del($key); // Redis doesn't support empty lists
|
self::$redis[$pool]->set($key, []);
|
||||||
} else {
|
} else {
|
||||||
self::$redis[$pool] // Ensure atomic
|
self::$redis[$pool] // Ensure atomic
|
||||||
->multi(Redis::MULTI)
|
->multi(Redis::MULTI)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user