Caching remedies like MemCache
and also Redis constantly maintain expiry,
while changing a worth to stay clear of any type of inconsistencies triggered by it.
Formerly, while incrementing
or decrementing an integer worth in MemoryStore,
Bed rails made use of to reset the expires_in
connected with the entrance, for eg-
Prior To
Allow’s claim, we are saving specific variety of sort on an item
as a like_counter
in MemoryStore for 10 secs.
Below, if we increment
or decrement the counter,
it is made use of to reset the TTL.
irb( primary): 004: 0>> cache = ActiveSupport:: Cache lookup_store(: memory_store)
irb( primary): 004: 0>> cache compose(" like_counter", 1, raw: real, expires_in: 10 secs)
irb( primary): 004: 0>> rest( 2 secs)
irb( primary): 004: 0>> cache increment(" like_counter")
irb( primary): 004: 0>> rest( 8 secs)
irb( primary): 004: 0>> cache read(" like_counter")
irb( primary): 004: 0>> 2
As we can see after 10 secs, like_counter
need to have been removed from the shop, nonetheless,
it still reveals the incremented worth since cache.increment(" like_counter")
established the timer
once again to 10 secs.
After
Currently, Bed rails maintains expires_in while incrementing
or decrementing an integer worth in MemoryStore.
irb( primary): 004: 0>> cache = ActiveSupport:: Cache lookup_store(: memory_store)
irb( primary): 004: 0>> cache compose(" like_counter", 1, raw: real, expires_in: 10 secs)
irb( primary): 004: 0>> rest( 2 secs)
irb( primary): 004: 0>> cache increment(" like_counter")
irb( primary): 004: 0>> rest( 8 secs)
irb( primary): 004: 0>> cache read(" like_counter")
irb( primary): 004: 0>> nil
As it can be seen,
though we had actually incremented the counter,
the crucial obtained ended after 10 secs
and also returned nil
Look Into
the PUBLIC RELATIONS
for even more information.