Skip to content

Instantly share code, notes, and snippets.

@Aung-Myint-Thein
Last active January 31, 2021 10:32
Show Gist options
  • Save Aung-Myint-Thein/a83af61a9e586a20f0005922dccc8d62 to your computer and use it in GitHub Desktop.
Save Aung-Myint-Thein/a83af61a9e586a20f0005922dccc8d62 to your computer and use it in GitHub Desktop.
Sample function call to redis
const { getCachedDataByKey, setDataToCache } = require('../../redis');
const checkUser = async (user_id, item) => {
let user_access = await getCachedDataByKey("item_access_" + item + "_" + user_id);
if (!user_access) {
// get the data from database for user_id for item and assign to user_access
setDataToCache("item_access_" + item + "_" + user_id, user_access);
}
return user_access;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment