cashews icon indicating copy to clipboard operation
cashews copied to clipboard

Check backend setup

Open liuzheyu1998 opened this issue 3 years ago • 2 comments

Hi, I am currently trying to integrate Redis cache to my application, while I am not quite sure about the setting up of Redis cache using cashews. For example, after I started a Redis server at terminal I got redis-cli 127.0.0.1:6379> ping PONG I wonder what is the correct format of the cache.setup using cashews.cache.

Any feedback will be greatly appreciated.

liuzheyu1998 avatar Jul 29 '22 01:07 liuzheyu1998

Hi.

While I try to find answer for your question I found that there is no clear way to check setup of cache. Here some option to do it and in future I will add more simpler way First option that may help is also a PING method, it should fail if you use unsafe mode with cache :

import asyncio
from cashews import cache

cache.setup("redis://", safe=False)
print(asyncio.run(cache.ping(b"test")))

Even with safe mode you can check a returning of a ping method , it should be the same as you pass to it ( but do not use PONG - it is a bug)

import asyncio

from cashews import cache

cache.setup("redis://")
print(asyncio.run(cache.ping(b"message")) == b"message")

# False

Krukov avatar Jul 29 '22 17:07 Krukov

Thank you a lot for your suggestion.

liuzheyu1998 avatar Jul 31 '22 13:07 liuzheyu1998