aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ng/cacheFactory.js2
-rw-r--r--test/ng/cacheFactorySpec.js5
2 files changed, 7 insertions, 0 deletions
diff --git a/src/ng/cacheFactory.js b/src/ng/cacheFactory.js
index 850d48f2..2ff02a37 100644
--- a/src/ng/cacheFactory.js
+++ b/src/ng/cacheFactory.js
@@ -70,6 +70,8 @@ function $CacheFactoryProvider() {
remove: function(key) {
var lruEntry = lruHash[key];
+ if (!lruEntry) return;
+
if (lruEntry == freshEnd) freshEnd = lruEntry.p;
if (lruEntry == staleEnd) staleEnd = lruEntry.n;
link(lruEntry.n,lruEntry.p);
diff --git a/test/ng/cacheFactorySpec.js b/test/ng/cacheFactorySpec.js
index dc68b63d..88e8e523 100644
--- a/test/ng/cacheFactorySpec.js
+++ b/test/ng/cacheFactorySpec.js
@@ -89,6 +89,11 @@ describe('$cacheFactory', function() {
}));
+ it('should return undefined when entry does not exist', inject(function($cacheFactory) {
+ expect(cache.remove('non-existent')).toBeUndefined();
+ }));
+
+
it('should stringify keys', inject(function($cacheFactory) {
cache.put('123', 'foo');
cache.put(123, 'bar');