Skip to content

Release v5.0.0

Choose a tag to compare

@awolverp awolverp released this 18 Apr 14:39
· 44 commits to main since this release
f6a6f47

Notable changes are listed:

Added

  • A new method named random_key added to RRCache.
  • A new method named expire added to TTLCache.
  • Some new methods added to VTTLCache: expire, items_with_expire.
  • TTLCache now supports timedelta as ttl.
  • VTTLCache now supports timedelta and datetime as ttl.
  • A new method copy added to all caches.

Changed

  • Now the errors which occurred while doing __eq__ operations will not be ignored:
class A:
    def __hash__(self):
        return 1
    def __eq__(self, other):
        raise NotImplementedError("not implemeneted")

cache = cachebox.FIFOCache(0, {A(): 10})

cache[A()]
# Traceback (most recent call last):
# File "script.py", line 11, in <module>
#    cache[A()]
#    ~~~~~^^^^^
#  File "script.py", line 7, in __eq__
#   raise NotImplementedError("not implemeneted")
# NotImplementedError: not implemeneted
  • __repr__ methods refactored:
cachebox.LRUCache(100, {i:i for i in range(100)})
# cachebox._cachebox.LRUCache[100/100]({0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15, 16: 16, 17: 17, 18: 18, 19: 19, 20: 20, 21: 21, 22: 22, 23: 23, 24: 24, 25: 25, 26: 26, 27: 27, 28: 28, 29: 29, 30: 30, 31: 31, 32: 32, 33: 33, 34: 34, 35: 35, 36: 36, 37: 37, 38: 38, 39: 39, 40: 40, 41: 41, 42: 42, 43: 43, 44: 44, 45: 45, 46: 46, 47: 47, 48: 48, 49: 49, 50: 50, ... 49 more ...})
  • The CacheInfo.cachememory renamed to CacheInfo.memory.

Removed

  • The n parameter of the LRUCache.least_recently_used method has been removed.

For more info, see changelog