Skip to content

CacheRepository will discard puts with expiration < 1 minute #10504

@sfudeus

Description

@sfudeus

The put interface for the CacheRepository allows to give minutes (as int) or a DataTime object to define the expiry of the cache item. When giving a DateTime object (e.g. using Carbon), which is less than 1 minute in the future, the cache entry will (unexpectedly) not be done, since the timestamp is transformed to "minutes in the future" again and 0 is considered null, which leads to skipping the write operation.

There was a report (#2954) on a similar issue a while ago (in Laravel 4), which was marked as "fixed".
I understand the API does define "int" and by that describe that smaller values are not usable - but in parallel a DateTime object is allowed and there is no documentation stating that small expiration are not unsupported. Caching for a small amount of time and not caching at all can make a large difference.

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