yiling-j / cacheme Goto Github PK
View Code? Open in Web Editor NEWAsyncio cache framework for Python
License: BSD 3-Clause "New" or "Revised" License
Asyncio cache framework for Python
License: BSD 3-Clause "New" or "Revised" License
With the help of type hints it's possible to limit key function's signature, just the same way as Cacheme. Using a separate function avoids the weird lamda or f-string in original decorator
@Cache("tlfu", 10000)
async def get_user_info(user_id: int) -> Dict:
return {}
# or use existing cache
cache = Cache("tlfu", 10000)
@cache
async def get_user_info(user_id: int) -> Dict:
return {}
# register key function: function name is not important, so just use _ here
@get_user_info.key
def _(user_id: int) -> str:
return f"user:{user_id}"
Add option in settings to enable compress for value byte size larger than given threshold
Based on the experience of cacheme-go, proposal following improvements:
Now I use string to set key in decorator, this is not easy for management, also user may have typos. So separate keys into a new python file, make them class, and just import in decorator maybe a better choice
Currently Cacheme overhead is too high, the local storage performance is much worse than native Theine API, need to improve: 1. try replace async event with awaitable, 2. optimize get/get_many, simplify code
I'm working a Starlette project that uses Pydantic v2. I'd be interested in trying out cacheme, but the conflicting Pydantic version requirements make it impossible. Two obvious options present themselves:
object_encoder
/object_decoder
on the Serialization classes, with the default being an identity function for accepting/returning primitive types.Thank you for considering this.
Meta keys just store set of key names, for example, delete meta key set stores deleted key names. Becasue key names are always short string, to make use of hash-max-ziplist-entries and save some memory, we can just bucket key name, just as instagram do Storing hundreds of millions of simple key-value pairs in Redis.
My idea is add some options to node or node fields, so we can dynamically bucket node keys. Each node will has its own meta keys namespace, and depend on node fields, we calculate the meta key info.
Or maybe hash the key and use bitmap to store those info.
class META
to node, then we can put attributes there, for example timeout
stale
option to global settings, also decorator and nodeA declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.