Skip to content

A simple Python dict with TTL support for auto-expiring caches with support for case-insensitive keys.

License

Notifications You must be signed in to change notification settings

augadhverma/expiring-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

expiring-cache

A simple Python dict with TTL support for auto-expiring caches with support for case-insensitive keys.

Installation

pip install expiring-cache

Features

  • TTL support for auto-caching
  • Case-insensitive keys support

Usage

Example 1:

import time
from cache import ExpiringCache

cache = ExpiringCache(2) # Keys will exist for 2 seconds.

cache['ABC'] = 'Example value'
print(cache['ABC']) # Prints the 'Example Value'
time.sleep(2)
print(cache['ABC']) # Raises KeyError

Example 2: (shows case-insensitive feature)

import time
from cache import ExpiringCache

cache = ExpiringCache(2, case_insensitive=True)

cache['ABC'] = 'Example value'
print(cache['ABC'])
print(cache['abc'])
# Both print statements above print the exact same 'Example Value'

time.sleep(2)
print(cache['ABC'])
print(cache['abc'])
# Both the print statements above raise KeyError

About

A simple Python dict with TTL support for auto-expiring caches with support for case-insensitive keys.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages