i2mint / py2store

Tools to create simple and consistent interfaces to complicated and varied data sources.
MIT License
11 stars 2 forks source link

async read cache-aside, and a footstep towards `async_this` store decorator #62

Open thorwhalen opened 4 years ago

thorwhalen commented 4 years ago

The read cache-aside pattern pops up often enough, but right now the implementation is sequential, which slows things down a bit. In the case where the data is not in the cache, once it's retrieved from its source, it would be nice for the process of caching not to block the user from starting to use the data immediately.

So instead of the current (see mk_memoizer in caching.py):

...
cache_store[k] = val  # cache it
return val

we'd like

...
async_this('cache_store[k] = val')  # cache it asynchronously
return val

Could be very easy, but need to think about what this could cause, and if the potential "harm" is important. For example:

cache-aside