nickschot / lux-redis-cache

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

request[requestKey].enabled broken in addToRedis #15

Closed jamemackson closed 7 years ago

jamemackson commented 7 years ago

This flag is coming into addToRedis as a string and not a boolean so the check of if(request[requestKey].enabled){ is not resulting properly when disabled resulting in the caching always being active.

https://github.com/nickschot/lux-redis-cache/blob/ad35f41af74884cdc5d69c7d855127dc59f55566/lib/index.js#L114

nickschot commented 7 years ago

Is it? It shouldn't be a string! Who's serializing?!

(Will check tomorrow ;-) )

jamemackson commented 7 years ago

yup, I believe when it gets backed into the request it's being serialized as a string and then staying that way when it's pulled back out in addToRedis. as it is, you can set enabled to false all you want but the cache will keep on caching ;)

nickschot commented 7 years ago

Unfortunately I can't seem to reproduce this. typeof enabled shows boolean in both middlewares for me.

Just double checking: you are actually passing a boolean?

jamemackson commented 7 years ago

yes I double checked this. I'm using node 7.6, maybe that makes a difference? Odd you aren't seeing the same behavior though. 🤔

nickschot commented 7 years ago

I've tested on 7.9.0 lastly, don't think that should make a difference (as 7.6 was the major change). I wouldn't know what'd serialize it on the way. Are you by any chance doing that yourself?

jamemackson commented 7 years ago

nope. it's fine. we can close this out. I'll re-open if this presents itself again.