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
Purpose of tags if not for search? #163
Comments
The tags mainly support eviction: http://www.grantjenks.com/docs/diskcache/api.html#diskcache.Cache.evict For example, I used them once when doing dynamic image resizing on the server. The client could request an image of a particular size and the server would grab the image from a blob store and then resize it and cache the resized image. When the resized image was cached, it would use a key like "image-1234-size-1024-by-768" and include "image-1234" in the tag. Later if the client uploaded a new image and replaced "image-1234" then I would evict all items with tag "image-1234" from the cache. Tags can also be simple metadata (they don't have to be strings). When retrieving a tag via get() you can request the tag too. I used that once for an expensive API call. I didn't want to change the key or value but I wanted to include some metadata to record how long the item took to generate. I stored that information as a float in the tag. |
Makes sense. And having arbitrary tags is cool, but would make using them for search not exactly easier. But I still think it would be helpful to have an analog operation to |
Maybe but I don’t see a compelling use case. Seems easy to use iterkeys() and get() as a start. |
|
That’s a good point. What’s your use case? |
I'm mostly interested in searching and ordering for keys, or alternatively for tags. When you work with geohashes e.g. you want to access a hash "next to" another one in your cache. https://github.com/litl/park e.g. has lexical traversal of keys. |
I see. That’s helpful. So you’d like to do bounds/prefix queries on both the keys and tags? It seems possible given the indexes are there. But the API for that functionality is not obvious to me. Maybe like: irange_keys(lo=None, hi=None, inclusive=(True, True), keys=True, values=False, tags=False) irange_tags(lo=None, hi=None, inclusive=(True, True), keys=True, values=False, tags=False) The “prefix” case looks special for strings. I’m not sure it should be included. |
It might also make sense to have two separate caches: key-value and key-tag. |
I've stumbled over this exciting project! Congrats!
Looking at tags I thought they might be very useful for searching items, but I don't see how that would work. And hence, what their intended purpose is right now? Also there is a statement in #118 that search in not a goal for this project. I understand that adding saerch feature would make DiskCache look more like a real database, though.
The text was updated successfully, but these errors were encountered: