Created
October 23, 2019 23:41
-
-
Save medisoft/df7e0d2534bcf79e7917abceba9b5630 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this one adds "function cache" in redis, caching the final result, of processed data