node-cached icon indicating copy to clipboard operation
node-cached copied to clipboard

Using express session as backend?

Open jasonkarns opened this issue 9 years ago • 1 comments

Just curious if anyone has attempted using an express request session as a backend. The sessions are already memcached, and leveraging the session would save a memcached call since the session will have already been hydrated before cached calls. I admit, it's a rather odd use case. Especially considering the weirdness for a Cache's backend to essentially be swapped out (as a single Cache would have its backend "swapped" for each request).

But curious if anyone else has attempted to use cached wherein a specific backend instance is supplied for each Cache method call.

jasonkarns avatar Sep 19 '16 13:09 jasonkarns

Interesting idea! I'm not aware of anyone doing that (yet). It might be possible to do it generically for "external object backed", e.g. an in-memory backend with "bring your own object".

The downside of "It's just one cache operation!" is that everything has to fit into one cache value. Which can become problematic for memcache in particular.

Maybe a "transaction mode" for caches would be a better fit for this problem (assuming it's not all data that's super small & user-specific)? E.g. some form of cache.multiGetOrElse has already been proposed in other places. It might also be possible to collect set operations and bulk them up.

hybrist avatar Sep 19 '16 16:09 hybrist