Magento2 – Redis L2 Cache Preload Suffix :hash or :version

cachemagento2redis

Reading the Magento 2 documentation is a little bit confusing.

Should I use the suffix :hash or :version?

If you visit https://devdocs.magento.com/guides/v2.4/config-guide/redis/redis-pg-cache.html#redis-preload-feature

When using the preload feature with the L2 cache, add the ‘:hash’ suffix to your keys:

'preload_keys' => [
    '061_EAV_ENTITY_TYPES:hash',
    '061_GLOBAL_PLUGIN_LIST:hash',
    '061_DB_IS_UP_TO_DATE:hash',
    '061_SYSTEM_DEFAULT:hash',
],

If you visit https://devdocs.magento.com/guides/v2.4/config-guide/cache/two-level-cache.html

We also recommend the use of the cache preload feature, as it will drastically decrease the pressure on Redis. Do not forget to add suffix ‘:version’ for preload keys.

Best Answer

If you use Redis adapter, then you need to specify keys in format: {cache_prefix}{key_name}

If you use L2 adapter, then you need to specify keys in format as it load only hashes from Redis and data from local storage (if present): {cache_prefix}{key_name}:hash

see: https://github.com/magento/magento2/blob/2.4-develop/lib/internal/Magento/Framework/Cache/Backend/RemoteSynchronizedCache.php#L47

Related Topic