Skip to content

Instantly share code, notes, and snippets.

@medisoft
Created October 23, 2019 23:41
Show Gist options
  • Save medisoft/df7e0d2534bcf79e7917abceba9b5630 to your computer and use it in GitHub Desktop.
Save medisoft/df7e0d2534bcf79e7917abceba9b5630 to your computer and use it in GitHub Desktop.
const keyHash = (params) => {
let hash = '';
_.each(params, (val, key) => {
hash+=`${key}:${val}`;
});
return hash;
}
const genericRead = async (params, callback = false) => {
const hash = keyHash(method, params);
if(await redis.existAsync(hash)) return await redis.getAsync(hash);
const rs = execQuery(.....);
.... do some processing to rs ....
const result = <dataProcessed>;
return await redis.setAsync(hash, result).then(()=>result);
}
@medisoft
Copy link
Author

this one adds "function cache" in redis, caching the final result, of processed data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment