Skip to content

cache: store empty arrays instead of refusing them #15702

Closed
2 of 3 issues completed
Closed

Description

@ArnabChatterjee20k

Problem

Every utopia-php/cache adapter refuses to store an empty array. save() starts with if (... || empty($data)) return false;, and Cache::saveWithLease() has the same check. The caller gets false with no error, and the next load() is a miss, so an empty result (no WAF rules, an empty HIBP range, a JWKS with no usable keys) is fetched from its source again on every request.

Checks in packages/cache/src: Adapter/Redis.php:167, Adapter/Redis/Multiplexing.php:240, Adapter/RedisCluster.php:114, Adapter/Memory.php:69, Adapter/Memcached.php:68, Adapter/Hazelcast.php:71, Cache.php:262 (saveWithLease).

Solution

Let [] be stored. '' and '0' stay refused as today.

Filesystem and Storage are left unchanged. They store strings and join arrays, so a stored [] would read back as '', and they keep refusing empty values.

Callers checked

Every write in appwrite/appwrite, appwrite-labs/cloud, appwrite-labs/edge, utopia-php/database (7.3.9 and 10.1.4) and the absorbed packages was traced. None relies on [] being refused, and none can serve a stale empty array that is never invalidated. These callers gain:

Released as a new major of utopia-php/cache, because the documented behaviour changes.

Sub-issues

Sub-issues

2 of 3 Issues completed
Loading 3 sub-issues

Activity

  1. changed the title [-]cache: store empty values ([], '', '0') instead of refusing them[/-] [+]cache: store empty arrays instead of refusing them[/+] on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions