You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
File-based cache corrupted / unserializable data in decode() method #929
When using the File-based cache driver, the stored serialized data sometimes cannot be unserialized correctly.
The library throws an exception or marks the item as corrupted.
Exception Failed to unserialize data from the cache, expected array or null but got boolean. Stored data may be corrupted.
Example error message (from logs or exception):
Unserialization failed or corrupted cache data in DriverBaseTrait::decode()
Observed Data Example
Below is a snippet of the actual data stored on disk (partial for readability):
decode() should be able to safely and fully unserialize all data that was previously serialized by phpFastCache, or gracefully handle partial/corrupted files without failing the entire pool.
Code sample (optional)
No response
Suggestion to fix the issue (optional)
No response
References (optional)
No response
Do you have anything more you want to share? (optional)
The corruption typically happens with large datasets (thousands of array entries).
The data is written fully (no truncated file size), but unserialization fails. It might also possible that serialization is going to failed.
Possibly related to file locking or concurrent writes during cache tag updates (TAG* files).
Your server is probably getting too many requests per seconds and is unable
to write cache on disk fast enough. It is not a library issue but rather a
race condition issue.
Try using a memory key-value cache instead like Memcache or Redis.
Cordialement/Cheers,
Georges.L
Activity
github-actions commentedon Oct 13, 2025
Hello curious contributor !
Since it seems to be your first contribution, make sure that you've been:
If everything looks unclear to you, tell us what 😄
The Phpfastcache Team
Geolim4 commentedon Oct 13, 2025
Hello,
You're might face a race condition issue.
Use "preventCacheSlams" option to avoid that.
Cheers,
Georges
hardik-office commentedon Oct 13, 2025
Hello @Geolim4, I have enabled preventCacheSlams and still getting the same issue,
Geolim4 commentedon Oct 13, 2025