Closed rmckeel closed 8 years ago
You can already achieve the functionality you're looking for (determine whether a key has been set) with Cache#info([key])
.
var myCache = cache.getCache('myNamespace');
myCache.set('A', 0);
myCache.set('B', undefined);
!!myCache.get('A'); // false
!!myCache.info('A'); // true
!!myCache.get('A'); // false
!!myCache.info('A'); // true
So if your inexperienced developer writes if(myCache.info('A')) {...}
it will still work as intended, even if the value set for that key is falsey. If you pass a key to Cache#info([key])
but the key has not been set, then undefined
will be returned.
Thank, @jmdobry. That makes sense, but being new to angular-cache, I wouldn't have found it on my own!
I believe updating the documentation to include a similar use case / example would help others like myself.
Thanks!
Hello,
Nice work on this library!
It would be nice to have a .has function in addition to .get. Consider the following scenarios:
Instead of having to iterate over keys to see if it actually has been set, a
.has
function would clear this up.Thoughts?