Closed sthomp closed 10 years ago
@sthomp I see what you're saying. Would the following suit your needs?
var itemToTouch = cache.get(someKey);
if (itemToTouch) {
cache.put(someKey, itemToTouch);
}
or would you be better served with a AngularCache#touch(key)
method being added to the API?
Yep that's similar to what Im currently doing:
if(itemToTouch){ cache.remove(someKey); cache.put(someKey, itemToTouch); }
I wasn't clear if I needed the remove().
I've written a small function called getAndTouch() that will return the item and touch it if it exists. Works fine for me but not sure if thats something you want to build into your core API.
This is mainly for TTL values. It would be nice to be able to 'touch' elements in the cache. The expected behavior would be that the timer for the given element would reset.