-
Notifications
You must be signed in to change notification settings - Fork 163
implement valkey support #975
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: amirreza <amir.rsf1380@gmail.com>
Signed-off-by: amirreza <amir.rsf1380@gmail.com>
Signed-off-by: amirreza <amir.rsf1380@gmail.com>
Signed-off-by: amirreza <amir.rsf1380@gmail.com>
Signed-off-by: amirreza <amir.rsf1380@gmail.com>
notes about this PR:
i'll continue to debug the problems with the tests, they could be something obvious that my tired eyes can't see or something hard, idk, i really appreciate any help and ideas and tips some extra notes: also the packaging and development setup is painful |
Looking good. A bit of cleanup still to do and the tests need to pass, but looks like it's mostly good. |
should be noted that the lua script for cas had a bug as well
hi! I'm back so currently i fixed more importatnly tho, i looked into why tests are failing on the discussion about context managers, i have something like this in mind async with ValkeyCache(config=my_config) as cache:
await cache.set(...) where another idea i have is to use a classmethod async with ValkeyCache.with_context_manager(config=congi):
... this way we don't need to change the signature of but i do think config should be provided by the user, so they can configure it as they please p.s: i know the commits have gotten a bit messy, i'm keeping it like this so i can see diff, i'll clean it up before un-drafting |
There is no released version with the current signature. The first version is fine. |
Once the tests actually run in the CI, I might be able to help.
Don't bother, it makes reviewing more difficult. We'll squash commit the PR. |
Ah, that's awkward, there's also no pypy version for valkey-glide? |
https://github.com/valkey-io/valkey-glide/blob/main/python/pyproject.toml#L24 |
Is that a bug in glide? From what I see at a glance, the _reader_loop() task is never awaited on. It looks like it's been cancelled here, which appears to only happen when the client is garbage collected. Either we're not closing the client correctly, or glide is depending on |
Oh, well, pip can't find it to install on the pypy job for some reason. |
@amirreza8002 @Dreamsorcerer Having said that, we will look into an option to integrate the close() logic into the destructor. I am pretty sure we've already tried but will re-investigate |
I think you got that the wrong way round. You can't close in the destructor, we just missed the close() call originally. Only (minor) concern I see is that the close() method should probably await the _reader_loop() task to ensure any exceptions etc. get raised correctly (like https://docs.aiohttp.org/en/stable/web_advanced.html#complex-applications). |
cleaned up some stuff btw did my comments on context manager come through? |
Which ones? |
i left two comments on your review on context manager. |
first comment: so i did try that, there is one issue tho: since glide clients are made by awaiting the create() method, we can't do that in init class ValkeyCache(...):
def __init__(self, config, ...):
self.client = await GlideClient.create(config=config) # error
async def __aenter__(self):
return self
async def __aexit__(self, *args, **kwargs):
await self.client.close() or is there something i'm missing? |
i have two designs in mind class ValkeyCache(...):
def __init__(self, config, ...):
self.config = config
async def __aenter__(self):
await connect()
return self
async def __aexit__(self, *args, **kwargs):
await self.client.close()
async def connect(self):
self.client = await GlideClient.create(config=self.config) and document that the user should await on connect after instantiation or: class ValkeyCache(...):
def __init__(self, config, ...):
self.config = config
async def __aenter__(self):
self.client = await GlideClient.create(config=self.config)
return self
async def __aexit__(self, *args, **kwargs):
await self.client.close()
@classmethod
async def connect(cls, config):
client = await GlideClient.create(config=config)
self = cls(config=config)
self.client = client
return self and instantiate using classmethod admittedly both are somewhat ugly |
Maybe you started a review and didn't submit the review?
Just create the client in
You mean a Cache? I don't think we need another way to do so. The user can just call |
only context manager is supported to instantiate ValkeyBackend
@asafpamzn @ikolomi Could one of you confirm the situation with Pypy support? |
we discussed pypy here : valkey-io/valkey-glide#3553 is the general feeling around this PR good? |
the glide team have informed me that pypy issue is fixed |
Yeah, that's only a couple of weeks, so maybe we wait for that and then cleanup this PR. |
hi again 🙌🏼 |
hi @ikolomi @asafpamzn but even when i build it in my own system, in a pypy env, it doesn't seem to work, i'll open an issue for this one |
|
Are you referring to this error: https://github.com/aio-libs/aiocache/actions/runs/14851993441/job/41719836603?pr=975#step:6:364 It seems you dont have the protoc installed on the build system. Github runners dont include it i believe. Could you please verify |
So, there's no prebuilt wheels for pypy then? Would probably be very useful to have those from a user perspective. Looks like there's a libprotoc-dev package that can be apt installed, if that resolves the problem for now. |
ah I didn't see that part thanks for checking this out 🙏 i reopened the issue i had on glide's repo, since it seems to persist |
What do these changes do?
add support for valkey, using valkey-gilde
Related issue number
Fixes #882
Checklist