Skip to content
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

[6.x] Set Redis cluster prefix with PhpRedis #30461

Merged
merged 1 commit into from
Oct 30, 2019
Merged

[6.x] Set Redis cluster prefix with PhpRedis #30461

merged 1 commit into from
Oct 30, 2019

Conversation

v0ctor
Copy link
Contributor

@v0ctor v0ctor commented Oct 30, 2019

When using the PhpRedis extension, the prefix is only set when connecting to a single server. Since RedisCluster class allows to set a prefix, this PR modifies PhpRedisConnector class to set the prefix when creating a cluster instance.

This PR fixes #25619.

By the way, there are no tests that cover cluster connections. Would it be possible to modify the Travis pipeline in some way to run a cluster? Thus, it would be possible to run all Redis tests in both cases.

@taylorotwell
Copy link
Member

Won't the cache system already prefix things? If we set the prefix at the Redis level then won't the cache double-prefix?

@v0ctor
Copy link
Contributor Author

v0ctor commented Oct 30, 2019

@taylorotwell Yes for the first answer, because it is the desired behaviour, and no for the second one.

On the one hand, there is the global prefix to avoid collisions among several projects using the same Redis server. On the other hand, there is the cache prefix to avoid collisions within the project itself.

If so, PhpRedisConnector::createClient() would not set the global prefix.

Example

# REDIS_PREFIX=laravel:
# CACHE_PREFIX=cache

Redis::set('foo', 'bar');
Cache::put('foo', 'bar');

With PhpRedis/Predis and a single Redis instance:

redis:6379> keys *
1) "laravel:foo"
2) "laravel:cache:foo"

With PhpRedis and a Redis cluster:

redis:6379> keys *
1) "foo"
2) "cache:foo"

With PhpRedis and a Redis cluster, after merging this PR:

redis:6379> keys *
1) "laravel:foo"
2) "laravel:cache:foo"

@taylorotwell taylorotwell merged commit 00ef166 into laravel:6.x Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid configuration prefix using phpredis
2 participants