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

Cannot use 'FLUSHDB' with redis-cluster #7

Closed
s1lver opened this issue Aug 22, 2022 · 8 comments
Closed

Cannot use 'FLUSHDB' with redis-cluster #7

s1lver opened this issue Aug 22, 2022 · 8 comments
Labels

Comments

@s1lver
Copy link
Member

s1lver commented Aug 22, 2022

What steps will reproduce the problem?

  1. Set up Redis cluster
  2. Call method $this->instance->clear()
public function clear(): bool
{
    return $this->client->flushdb() !== null;
}

What is the expected result?

Completed cleaning

What do you get instead?

I get an exception

Additional info

Q A
Version 1.0.0
PHP version 8.0.21
Operating system Alpine
Redis 6.2.6 - 7.0.4
@samdark samdark added the type:bug Bug label Aug 22, 2022
@samdark
Copy link
Member

samdark commented Aug 22, 2022

What's the exception?

@s1lver
Copy link
Member Author

s1lver commented Aug 23, 2022

What's the exception?

Exception 'Predis\NotSupportedException' with message 'Cannot use 'FLUSHDB' with redis-cluster.'

@s1lver
Copy link
Member Author

s1lver commented Aug 23, 2022

I wrote a couple of tests connecting to a Redis cluster. Can I change CI using single Docker config locally and in Github Actions?

How in general are local tests being launched now?

@samdark
Copy link
Member

samdark commented Aug 24, 2022

Can I change CI using single Docker config locally and in Github Actions?

Isn't it possible to lauch cluster as a service in actions?

How in general are local tests being launched now?

With a local instance of PHP/Redis.

@s1lver
Copy link
Member Author

s1lver commented Aug 24, 2022

Can I change CI using single Docker config locally and in Github Actions?

Isn't it possible to lauch cluster as a service in actions?

Yes it is possible

s1lver added a commit to s1lver/cache-redis that referenced this issue Aug 24, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Aug 24, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Aug 24, 2022
@s1lver
Copy link
Member Author

s1lver commented Aug 24, 2022

@samdark
first to check I changed the CI and ran the current tests
https://github.com/yiisoft/cache-redis/runs/8004880416?check_suite_focus=true

Then I added identical tests with a connection to the cluster
https://github.com/yiisoft/cache-redis/runs/8005031578?check_suite_focus=true

@s1lver
Copy link
Member Author

s1lver commented Aug 25, 2022

Maybe check the activity of the cluster like this? And if it is active, then execute another command to clear

172.20.128.3:6382> info Cluster
# Cluster
cluster_enabled:1

s1lver added a commit to s1lver/cache-redis that referenced this issue Oct 31, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Oct 31, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Oct 31, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Oct 31, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Oct 31, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Oct 31, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Oct 31, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Oct 31, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Oct 31, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Oct 31, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Oct 31, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Oct 31, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Oct 31, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Oct 31, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Oct 31, 2022
…leteMultipleThrowExceptionForInvalidKeys, testGetMultipleThrowExceptionForEmptyArray, testSetMultipleThrowExceptionForEmptyArray tests
s1lver added a commit to s1lver/cache-redis that referenced this issue Nov 1, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Nov 2, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Nov 2, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Nov 2, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Nov 2, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Nov 2, 2022
s1lver added a commit to s1lver/cache-redis that referenced this issue Mar 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Mar 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Mar 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Mar 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Mar 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Mar 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Mar 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Mar 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Jul 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Jul 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Jul 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Jul 7, 2023
@s1lver
Copy link
Member Author

s1lver commented Jul 7, 2023

Predis independently routes commands, when specifying Redis nodes in the cluster, to the appropriate nodes, depending on the keys that are specified in the commands.

Therefore, you can use the set and get methods to implement MGET and MSET.

Implementing something like this

$slot = $client->getConnection()->executeCommand(new RawCommand('CLUSTER KEYSLOT', [$key]));
$client->getConnection()->executeCommand(new RawCommand('CLUSTER SETSLOT', [$slot, 'IMPORTING']));
$valuesFromCache[$key] = $client->getConnection()->executeCommand(new RawCommand('GET', [$key]));
$client->getConnection()->executeCommand(new RawCommand('CLUSTER SETSLOT', [$slot, 'NODE']));

would be redundant.

You can also manually check the receipt of the key in the cluster using the redis-cli
image

s1lver added a commit to s1lver/cache-redis that referenced this issue Jul 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Jul 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Jul 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Jul 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Jul 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Jul 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Jul 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Jul 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Jul 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Jul 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Jul 7, 2023
s1lver added a commit to s1lver/cache-redis that referenced this issue Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants