3

I am looking at the documentation for the expire field in the cache tables and the documentation in CacheBackendInterface.php says:

@param int $expire
One of the following values:

  • CacheBackendInterface::CACHE_PERMANENT: Indicates that the item should not be removed unless it is deleted explicitly.
  • A Unix timestamp: Indicates that the item will be considered invalid after this time, i.e. it will not be returned by get() unless $allow_invalid has been set to TRUE. When the item has expired, it may be permanently deleted by the garbage collector at any time.

When I look in a cache table, for example cache_render, I see that many entries have NULL in the expire column and I noticed it only get clear on a complete cache clear, such as after running drush cr.

What does a null value set for the expire column in a cache table mean?

3
  • 3
    I don't see entries having NULL in cache_render and I don't see a problem if there were any. Cache entries are not deleted if they become invalid. Cron deletes them after a while, and any cache entry having an expire value less than the current time and not CACHE_PERMANENT are deleted.
    – 4k4
    Mar 16 '19 at 9:13
  • @4k4 thank you. I need to do more digging to see where the null entries are coming from. I suspect a contrib module. I found this after noticing blocks were not updating after editing them until I cleared the cache, more specifically cache render.
    – awm
    Mar 18 '19 at 15:21
  • This would be a different issue. A cache item gets cleared after editing if it has the correct cache tag.
    – 4k4
    Mar 18 '19 at 16:25
0

Any value for the expire column that is different from CacheBackendInterface::CACHE_PERMANENT (-1) is considered a timestamp, indicating when the cache entry could be deleted. In the case of NULL, the value means the cache entry could be deleted in any moment.
As @4k4 said in his comment, data in cache tables are deleted when cron tasks run, and that doesn't necessarily means immediately.

The only issue with NULL is whether a module is using a not initialized variable which is expected to contain the expiration time. In that case, the cached value is kept in cache less than required.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.