Conversation
mqudsi
left a comment
There was a problem hiding this comment.
Hey thanks for contributing. I agree that it would be useful to have this functionality and I'm not against adding it via the concrete type given that, unlike with redis-backed caches or whatever, you can't just connect to the instance and run flush all.
I'm going to assume that clearing the cache is not a common operation, so I think it probably makes sense for me to push a commit to remove the query from the query cache instances and use it directly at the call site, unless you have any other suggestions.
There are now two `Use()` overloads, one for the command + connection (existing) and one for the connection alone (new). The new one can be used when we need to borrow a connection from the shared pool but don't want to use it with a command from the command pool.
Implement `SqliteCache.Clear()` without going through the command pool, using the new `DbCommand.Use()` override that borrows a connection w/out a command, then creating the command and using it locally. Assuming that calls to `SqliteCache.Clear()` are not typically going to be in the hot path, this will reduce the memory usage by not leaving cached instances of the `DbCommand` around after the call.
Fix the clear cache test. The persistence test made no sense.
1ebfec0 to
db8aae3
Compare
|
Hi, sorry for the long response time. I saw your change to move the cmd out of the command pool. I think that's a design decision that's entirely yours :) My motivation for making "basic" command like this others were that I thought of it as a basic action. But if you don't think it'll be the "hot path", as you wrote, when that's all good. I'm just happy to have the clear cache functionality 👍 |
|
No worries. I keep feeling like the method should be named |
We have the need to clear the cache in our project, and have written code to access the sqlite db directly and clear it. I know IDistributedCache does not have a Clear method, but it would be nice to have as part of the "core" functionality.