A low level cache library.
Project description
cachecore
A low-level caching library with multiple implementations.
Can be used as a stand-alone cacheing library or can be used to create higher level caching libraries.
Basics
Get, set, delete, and check for the existence of a key using the following.
>>> import cachecore
>>> cache = cachecore.LocalCache()
>>> cache.set('a', 1)
>>> cache.get('a')
1
>>> cache.has_key('a')
True
>>> cache.delete('a')
True
>>> cache.has_key('a')
False
>>> cache.get('a')
None
Complete API
__getitem__(self, key: str) -> Any:
__setitem__(self, key: str, value: Any):
__delitem__(self, key: str):
__contains__(self, key: str):
__iter__(self):
__len__(self):
keys(self, pattern: str = None):
get(self, key: str, default: Any = None) -> Any:
set(self, key: str, value: Any, ttl: Optional[int] = None):
add(self, key: str, value: Any, ttl: Optional[int] = None) -> bool:
replace(self, key: str, value: Any, ttl: Optional[int] = KEEP_TTL) -> bool:
delete(self, key: str) -> bool:
pop(self, key: str, default: Any = None):
has_key(self, key: str) -> bool:
get_many(self, keys: Iterable[str], default: Any = None) -> Iterable[Any]:
set_many(self, mapping: Iterable[tuple[str, Any]], ttl: Optional[int] = None):
delete_many(self, keys: Iterable[str]) -> Iterable[bool]:
get_ttl(self, key: str, default: int = 0) -> Optional[int]:
set_ttl(self, key: str, ttl: Optional[int] = None) -> bool:
incr(self, key, delta=1) -> int:
decr(self, key, delta=1) -> int:
clear(self):
Cache Implementations
- Dummy
- Local Memory
- File System
- Memcached (Coming Soon)
- Redis
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cachecore-0.3.0.tar.gz
(7.3 kB
view hashes)
Built Distribution
Close
Hashes for cachecore-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e959106a80362e3c574b1434f1f1599dfbe3c364b84cedb2ee07a93c15ec0bb0 |
|
MD5 | 95e6924848f9d818c7c30dab02b060a5 |
|
BLAKE2b-256 | 4769a9e53c9ceb1ee092e80cb7da0595307d4ad78f26d7cb268af56f7626782d |