redis caching with mongodb
setup
To configure redis and MongoDB do
const rm = ; ;
To connect to a remote database click here
Redis handling
isCached
To check if an key is cached in redis you write the following
rm;
cache
To cache data you run the following function
rm;
Settigns could be the following
forceUpdate: true duration: -1
forceUpdate set to true overwrites the data if already cached duration is how long the key should be active, -1 is infinite
uncache
To uncache data the following function is called
rm;
Settings could be the following
forceDel: true duration: 10
forceDel deletes the key without taking duration into account duration sets a duration for when it should delete
MongoDB manipulation
set data
To set data you run the following function
rm;
settings can be
cache: true duration: 100 forceUpdate: false
cache is whether the data should be cached duration and forceUpdate is only taking into consideration if cache is true duration is how long the key should be cached forceUpdate overwrites any old cache with the same key
get data
to get data you run
rm;
settings can be
cache: true duration: 100 forceUpdate: false
cache is whether the data should be cached duration and forceUpdate is only taking into consideration if cache is true duration is how long the key should be cached forceUpdate overwrites any old cache with the same key
update data
to update data run
rm;
settings take
cache: true duration: 100 forceUpdate: false
cache is whether the data should be cached duration and forceUpdate is only taking into consideration if cache is true duration is how long the key should be cached forceUpdate overwrites any old cache with the same key
query is written in the following way
key: key // Any know data
delete data
delete data with
rm;
settings take
keepCached: true duration: 100
keepCached is if the data being removed should be stored duration is how long the key should be cached. Can't be -1 as it should be deleted