Skip to content

Cache::flexible does not refresh in the background between stale period #58174

@mnaviddoost

Description

@mnaviddoost

Laravel Version

12

PHP Version

8.3

Database Driver & Version

No response

Description

Hi. I am using the Cache::flexible method as follows:

$now = Cache::flexible('dateeeeee17', [10, 60], function () { return Carbon::now()->toTimeString(); }); return view('test', compact('now'));

Here is the behavior I am observing:

On the initial request, I get 12:00:00.
For the first 10 seconds (the "fresh" period), the cache correctly returns the same value.
Between 10 and 60 seconds (the "stale" period), I refresh the page several times at 5-second intervals. According to the documentation, the cache should refresh in the background during this period.
However, I still keep seeing the initial value (12:00:00). The new value only appears after 60 seconds, when the cache expires.
It seems that no background refresh is happening during the stale period, contrary to what the documentation suggests.
I have tried searching for existing issues or discussions but couldn’t find anything. Any guidance or confirmation on whether this is expected behavior would be appreciated.

Thank you!

Steps To Reproduce

no steps

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