Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Make RedisAdapter TagAware by using native Redis Sets #30624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
flaushi opened this issue Mar 21, 2019 · 4 comments
Closed

Make RedisAdapter TagAware by using native Redis Sets #30624

flaushi opened this issue Mar 21, 2019 · 4 comments

Comments

@flaushi
Copy link

flaushi commented Mar 21, 2019

The only way to have a cache adapter with tagging features in symfony currently is to explicitly create a TagAwareAdapter backed by some other cache adapter.

However, redis does have SETS, see https://www.compose.com/articles/how-to-handle-tagged-data-with-redis-sets/ and the official docs

Shouldn't it be possible to include this into the RedisAdapter just from the beginning? I'd expect massive performance improvements from this.

@dmaicher
Copy link
Contributor

See #30370 ? 😊

@nicolas-grekas
Copy link
Member

You're not the only one wondering about this, see #30370
Would you mind reviewing and trying that PR and give feedback on your findings there?

@flaushi
Copy link
Author

flaushi commented Mar 21, 2019

Ah wow, I did not search well enough...
I will try to do that.
Thanks for your quick response!

@flaushi
Copy link
Author

flaushi commented Aug 22, 2020

May I come back to this issue and ask (as a redis non-expert) if the changes have been applied?

I am unsing Symfony 4.4, and have a configuration like this:

cache:
        default_redis_provider: 'redis://%env(REDIS_HOST)%/%env(REDIS_DB)%'
        pools:
            tagged_data_cache:
                adapter: cache.adapter.redis
                default_lifetime: 0
                tags: true
services:
    _defaults:
        bind:
            $taggedDataCache: '@tagged_data_cache'

I am using the redis extension redis-4.3.0.
If I execute this code:

function bla(AdapterInterface $taggedDataCache)
{
    if($taggedDataCache->has('minmaxdate-0111669a-41cb-46f8-b598-8dbb1f9997ba)) {
        return $taggedDataCache->getItem('minmaxdate-0111669a-41cb-46f8-b598-8dbb1f9997ba)->get();
    }
    $i = $taggedDataCache->getItem('minmaxdate-0111669a-41cb-46f8-b598-8dbb1f9997ba);
    $i->set(...);
    $i->tag('0111669a-41cb-46f8-b598-8dbb1f9997ba');
    $taggedDataCache->save($i);
}

Then these commands are printed on redis-cli's MONITOR command:

1597997874.233465 [0 172.18.0.5:41714] "EXISTS" "cflIDBi3cW:minmaxdate-0111669a-41cb-46f8-b598-8dbb1f9997ba"
1597997874.233797 [0 172.18.0.5:41714] "MGET" "PVj5Gcu1j-:%5B4ecb6b0180cbbd8397e04aad594ea33b%5D%5B1%5D"
1597997877.025024 [0 172.18.0.5:41714] "MGET" "cflIDBi3cW:\x00tags\x00minmaxdate-0111669a-41cb-46f8-b598-8dbb1f9997ba" "cflIDBi3cW:minmaxdate-0111669a-41cb-46f8-b598-8dbb1f9997ba"
1597997877.025375 [0 172.18.0.5:41714] "SET" "cflIDBi3cW:minmaxdate-0111669a-41cb-46f8-b598-8dbb1f9997ba" "a:2:{i:0;O:13:\"Carbon\\Carbon\":3:{s:4:\"date\";s:26:\"2020-01-01 00:00:00.000000\";s:13:\"timezone_type\";i:3;s:8:\"timezone\";s:3:\"UTC\";}i:1;O:13:\"Carbon\\Carbon\":3:{s:4:\"date\";s:26:\"2020-07-01 00:00:00.000000\";s:13:\"timezone_type\";i:3;s:8:\"timezone\";s:3:\"UTC\";}}"
1597997877.025532 [0 172.18.0.5:41714] "MGET" "cflIDBi3cW:0111669a-41cb-46f8-b598-8dbb1f9997ba\x00tags\x00"
1597997877.025781 [0 172.18.0.5:41714] "SET" "cflIDBi3cW:\x00tags\x00minmaxdate-0111669a-41cb-46f8-b598-8dbb1f9997ba" "a:1:{s:36:\"0111669a-41cb-46f8-b598-8dbb1f9997ba\";i:0;}"

Question: are the native tags used here? I do not see any set commands like sadd.
Thanks in advance!

@flaushi flaushi reopened this Aug 22, 2020
@flaushi flaushi closed this as completed Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants