pinterest / pymemcache

A comprehensive, fast, pure-Python memcached client.
https://pymemcache.readthedocs.io/
Apache License 2.0
778 stars 179 forks source link

Delete key from every node #527

Closed Nerdyvedi closed 1 year ago

Nerdyvedi commented 1 year ago

Hi, I am trying to ensure there's 0 possibility of having stale data with a particular key. I am trying to solve this problem for the following scenario:

Now, if Node 1 goes down again, there is a possibility that I return data from Node 2 , which is stale.

jogo commented 1 year ago

Hi @Nerdyvedi, if you think this is a bug in pymemcache mind sharing the steps to reproduce the issue?

Nerdyvedi commented 1 year ago

@jogo , Don't think it's a bug. I want to know if there's a feature that could allow me to delete key from a specific server?

jogo commented 1 year ago

@jogo , Don't think it's a bug. I want to know if there's a feature that could allow me to delete key from a specific server?

got it, it depends on which specific client you are using. For the HashClient you can find all the individual clients in self.clients

Nerdyvedi commented 1 year ago

And let's say I want to delete a key from each server, I'll iterate through each client and call delete ?

Nerdyvedi commented 1 year ago

@jogo At this moment thr _run_cmd function takes in the cmd and the key. It then find the client from the key, and then runs the command.

There is no public function I can access that would allow me to delete key from specific client

Nerdyvedi commented 1 year ago

Do you think it makes sense to create a function something like delete_from_client, and pass in the client we want to delete the key from?

jogo commented 1 year ago

can you just do something like?

for client in my_hash_client.clients:
    client.delete(...)
Nerdyvedi commented 1 year ago

Got it, Thanks. Client has a delete function itself.

Nerdyvedi commented 1 year ago

@jogo Is there a way I can delete from individual clients using the builtin RetryingClient module?