Why aren't files from Zend Data Cache being removed automatically?

Follow

Issue

When using disk-backed Zend Data Cache, old files are not automatically removed.  This consumes disk space and filesystem resources.  How can these files be removed?

Environment

Zend Server 6, using Data Cache

Zend Server 7, using Data Cache

Resolution

The files must be removed explicitly.  This can be done programmatically by executing zend_disk_cache_delete or zend_disk_cache_clear.  The zend_disk_cache_delete function will remove targeted data, while the zend_disk_cache_clear function will remove all data entries.  Optionally, zend_disk_cache_clear can use a namespace for more tightly scoped data removal.

It is also possible to remove the full contents of the cache from Zend Server UI by navigating to Configurations > Components and clicking the broom icon to the right of Zend Data Cache.

Details

Zend Data Cache has no knowledge of whether data values should be removed, unless explicitly told.  The optional TTL parameter when storing values represents when the data is stale, rather than when it should be removed. It is the responsibility of the application to clean up stored data when it is no longer needed.  For some applications, it may be useful to issue zend_disk_cache_clear during app startup to ensure that the data cache starts with a clean slate.

The Zend Server documentation provides an overview of working with the data cache and the API.

Working with Data Cache

Zend Data Cache - PHP API

 

Have more questions? Submit a request

Comments

Powered by Zendesk