Krukov / cashews

Cache with async power
MIT License
406 stars 25 forks source link

Not working with GCP MemmoryStore (Redis) - unknown command 'CLIENT' #180

Closed shijo-keyvalue closed 9 months ago

shijo-keyvalue commented 9 months ago

We are migrating from AWS to GCP , and as part of it we have moved from ElasticCache(Redis) to Memmorystore (Redis). The cashews module seems to be working fine with ElasticCache(Redis) , But with Memmorystore(Redis) we are getting erros as given below.

When I checked , found that CLIENT command is not allowed in Memmorystore , which is related to an error we got in logs - unknown command 'CLIENT', with args beginning with: 'SETNAME' 'cashews'

Would like to know how can I use Cashews module along with Memmorystore. If this is a known issue , is there any workaround for it ?

Redis version used : redis==5.0.0 Cashews version used : cashews==6.3.0

Dec 30 18:19:58 ERROR   redis: can not execute command: SPOP
Dec 30 18:19:58 Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/cashews/backends/redis/client.py", line 26, in execute_command
    return await super().execute_command(command, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/integrations/redis/asyncio.py", line 70, in _sentry_execute_command
    return await old_execute_command(self, name, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/redis/asyncio/client.py", line 545, in execute_command
    conn = self.connection or await pool.get_connection(command_name, **options)
  File "/usr/local/lib/python3.8/site-packages/redis/asyncio/connection.py", line 1312, in get_connection
    await connection.connect()
  File "/usr/local/lib/python3.8/site-packages/redis/asyncio/connection.py", line 258, in connect
    await self.on_connect()
  File "/usr/local/lib/python3.8/site-packages/redis/asyncio/connection.py", line 353, in on_connect
    if str_if_bytes(await self.read_response()) != "OK":
  File "/usr/local/lib/python3.8/site-packages/redis/asyncio/connection.py", line 537, in read_response
    raise response from None
Dec 30 18:19:58 redis.exceptions.ResponseError: unknown command 'CLIENT', with args beginning with: 'SETNAME' 'cashews'
Krukov commented 9 months ago

Thanks for reporting, it's unknown issue, but probably you can try solve it by passing blank client_name to a setup call

cache.setup("redis://0.0.0.0/", client_name=None)

Looks like Memorystore do not support CLIENT SETNAME

shijo-keyvalue commented 9 months ago

@Krukov Its working after making the suggested changes. Thank you for the quick response. Appreciate it :)