nickschot / lux-redis-cache

[WIP] Middleware implementation of a redis based cache for Lux
MIT License
8 stars 1 forks source link

Use a sensible initialisation method #4

Open nickschot opened 7 years ago

nickschot commented 7 years ago

Right now some variables (like the cache expiry key) are shared between the get and set functions. A sensible way to share these must be thought of.

Example: Right now a global currentCacheKey variable exists and is used by both middleware functions. As there is only one it is overwritten by every call to the setter. This might not be desirable when using the middleware on specific routes instead of the application controller.

Furthermore options could be passed in just the beforeAction/get middleware. The get middleware could then pass it along to the set middleware via the request object (as it already does for the key).