aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--js/assets.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/js/assets.js b/js/assets.js
index e62bb5d..6e9c1f6 100644
--- a/js/assets.js
+++ b/js/assets.js
@@ -224,6 +224,47 @@
getCacheRegistry(onReady);
};
+ let cacheRemove = function (pattern, callback) {
+ let onReady = function (cache) {
+ let entries = [];
+
+ for (let key in cache) {
+ if (pattern instanceof RegExp && !pattern.test(key)) {
+ continue;
+ }
+
+ if (typeof pattern === 'string' && key !== pattern) {
+ continue;
+ }
+
+ entries.push(key);
+
+ delete cache[key];
+ }
+
+ if (entries.length !== 0) {
+ vAPI.cacheStorage.remove(content);
+
+ let bin = {
+ assetCacheRegistry: cache,
+ };
+ vAPI.cacheStorage.set(bin);
+ }
+
+ if (typeof callback === 'function') {
+ callback();
+ }
+
+ for (let i=0; i<entries.length; ++i) {
+ notifyObservers('after-asset-updated', {
+ assetKey: entries[i],
+ });
+ }
+ };
+
+ getCacheRegistry(onReady);
+ };
+
let markDirtyCache = function (pattern, exclude, callback) {
let onReady = function (registry) {
let entry;