I have a number of keys organized by tags and would like to get a list of keys with a certain tag. However, I cannot find a straightforward way to do this.
Current workaround:
for key in cache.iterkeys():
if cache.get(key, tag=True)[-1] == 'counter':
# ...
This approach is awkward and inefficient. It is of course possible to do
select = "SELECT key, raw, value FROM Cache WHERE tag = ?"
for key, raw, value in cache._sql(select, ('counter',))}:
# get key, value from key and raw
but I would prefer not messing with the internal of diskcache
Proposed enhancement: It would be beneficial to add a tag parameter to the iterkeys method to allow:
def iterkeys(self, reverse=False, tag=False):
This enhancement would simplify the code and improve efficiency when working with tagged keys.
I have a number of keys organized by tags and would like to get a list of keys with a certain tag. However, I cannot find a straightforward way to do this.
Current workaround:
This approach is awkward and inefficient. It is of course possible to do
but I would prefer not messing with the internal of
diskcacheProposed enhancement: It would be beneficial to add a tag parameter to the
iterkeysmethod to allow:This enhancement would simplify the code and improve efficiency when working with tagged keys.