ladda-cache
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -496,2 +496,13 @@ module.exports = | ||
} else { | ||
if (type.indexOf('(*)') !== -1) { | ||
var allMatcher = getAllMatcher(type.substring(0, type.length - 3)); | ||
var candidates = Object.keys(datastore.entityCache || {}); | ||
var toInvalidate = candidates.filter(function (x) { | ||
return allMatcher.test(x); | ||
}); | ||
toInvalidate.forEach(function (key) { | ||
delete datastore.entityCache[key]; | ||
}); | ||
datastore.queryCache[type.substring(0, type.length - 3)] = {}; | ||
} | ||
datastore.queryCache[type] = {}; | ||
@@ -502,2 +513,6 @@ } | ||
function getAllMatcher(type) { | ||
return new RegExp('^' + type + '.*$'); | ||
} | ||
function invalidateQueryCacheByFunction(datastore, type, method) { | ||
@@ -677,3 +692,3 @@ var matcher = getMatcher(type, method); | ||
function getFromCache(apiFn, datastore, type, query) { | ||
if (shouldUseQueryCache(apiFn.plural, apiFn.byId)) { | ||
if (apiFn.plural) { | ||
return getFromQueryCache(datastore, type, query, apiFn.name); | ||
@@ -685,6 +700,2 @@ } else { | ||
function shouldUseQueryCache(plural, byId) { | ||
return plural === true || byId === false; | ||
} | ||
function getFromQueryCache(datastore, type, query, apiFnName) { | ||
@@ -700,6 +711,5 @@ return (0, _datastore.getCollection)(datastore, createQueryForCollection(type, query, apiFnName)); | ||
return function (data) { | ||
if (shouldUseQueryCache(apiFn.plural, apiFn.byId)) { | ||
[apiFn.name].concat(apiFn.cacheAliases || []).map(function (fnName) { | ||
(0, _datastore.addCollection)(datastore, createQueryForCollection(abstractEntity.name, query, fnName), data); | ||
}); | ||
if (apiFn.plural) { | ||
var collectionQuery = createQueryForCollection(abstractEntity.name, query, apiFn.name); | ||
(0, _datastore.addCollection)(datastore, collectionQuery, data); | ||
} else { | ||
@@ -706,0 +716,0 @@ (0, _datastore.addItem)(datastore, (0, _query.createQuery)(abstractEntity.name, query), data); |
{ | ||
"name": "ladda-cache", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Data fetching layaer with support for caching", | ||
@@ -5,0 +5,0 @@ "main": "dist/bundle.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52890
26
1287