Skip to content

Conversation

9999years
Copy link
Contributor

Closes #197.

Comment on lines 347 to 348
// https://redis.io/commands/flushdb/
let _: () = redis::cmd("FLUSHDB").query(&mut *conn)?;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this delete someone's entire redis db? I think a scan + delete would need to be done instead, using the self.namespace + self.prefix in the scan

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I just assumed the Redis DB was already unique per cache. I can fix this.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ty!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a shot at it but needing two connections seems weird. scan_match needs &mut self, though, so I can't do anything with the deserialized values without opening another connection or collecting them all into memory first.

https://docs.rs/redis/latest/redis/trait.Commands.html#method.scan_match

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any plans to merge this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a while, but I reimplemented this with the scan + delete strategy. Should be ready now?

@LucaCappelletti94
Copy link

Hi all, is there any development regarding this feature? Was it possibly added in some other PR? I am looking for a way to clear the redis cache.

@9999years
Copy link
Contributor Author

@LucaCappelletti94 I just fixed up the merge conflicts and fixed up the async Redis cache_clear implementation, so it should be ready now, but in the meantime you can just write your own functions (or even an extension trait) with the same implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache clear operation
4 participants