I have a problem with proper configuration for redis in Symfony 4. I want to have no prefix before my cache item keys, but it is constantly showing. Here is my config/packages/framework.yaml
(part related to cache):
cache:
prefix_seed: ztw/ztw
app: cache.adapter.redis
default_redis_provider: '%env(resolve:REDIS_URL)%'
I tried to remove prefix_seed
key and setting its value to ~
. Nothing worked. However, documentation states that its default value is null
.
I want to achieve this because when I launch my website through the website, it sets some key and sticks to it. But when I run my behat tests (intentionally - to populate cache) - keys are different, no matter what. Both use APP_ENV=dev
environment variable value (checked twice).
Here is what's going on on the redis side:
127.0.0.1:6379> keys *
1) "xw+Y6oICD-:4dfbddf6bbb8ea2e25e843d936739dd9"
2) "xw+Y6oICD-:4f1cbb7ece6f8db3b69ae11418bbf022"
3) "xw+Y6oICD-:26c65dcee950a5020596989ad1a8ff66"
4) "gUbUjDoAuQ:b712bf9832f566bd5bd30a07e7bd146b"
5) "gUbUjDoAuQ:1d0f56bf67bd482674b62067336bd633"
6) "xw+Y6oICD-:d948f5e23f94e681620436786f0daf98"
7) "xw+Y6oICD-:ef88ab906981c6e04ef639cd4a8ae803"
8) "xw+Y6oICD-:748d18ce6ba0929d2540e9b4529e56cc"
9) "xw+Y6oICD-:ef30ff7e239b92cec1f5e58c201296f5"
10) "xw+Y6oICD-:1d0f56bf67bd482674b62067336bd633"
11) "xw+Y6oICD-:b712bf9832f566bd5bd30a07e7bd146b"
12) "xw+Y6oICD-:4da534491b5732336b3bb3e7302bc79b"
For example 4th and 11th item have the same key (and value) but different prefix, unfortunately.
I know that cache key prefix is considered a good practice, but for some reason while running through behat keys are different.
Any help appreciated.
The prefix_seed
mentioned above is the prefix for the symfony cache files (unrelated redis).
The default value for the redis prefix is PHPREDIS_SESSION:
which explains the keys you mentioned above, I've not tried this but I think you will need to add and set the prefix
option to an empty string in session.save_path
.
Check the predis read me file: https://github.com/phpredis/phpredis
Edit: according to the docs it looks like it's only possible to set extra settings via predis.
When using the Predis library some additional Predis-specific options are available. Reference the Predis Connection Parameters documentation for more information.
Source: https://symfony.com/doc/current/components/cache/adapters/redis_adapter.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With