From 98406fbe52f6f2998d17b1096ef8f28e982b1521 Mon Sep 17 00:00:00 2001 From: Raymond Rutjes Date: Sat, 5 Aug 2017 17:41:17 +0200 Subject: [PATCH] feat(store): add methods to interact with cache Closes: #241 --- src/store.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/store.js b/src/store.js index 232cd992f..279653ab5 100644 --- a/src/store.js +++ b/src/store.js @@ -53,6 +53,8 @@ export class Store { this._highlightPreTag = ''; this._highlightPostTag = ''; + this._cacheEnabled = true; + this.algoliaHelper = helper; } @@ -355,11 +357,25 @@ export class Store { }; } - // Todo: find a better name for this function. refresh() { + if (this._cacheEnabled === false) { + this.clearCache(); + } this._helper.search(); } + enableCache() { + this._cacheEnabled = true; + } + + disableCache() { + this._cacheEnabled = false; + } + + clearCache() { + this.algoliaClient.clearCache(); + } + waitUntilInSync() { return new Promise((resolve, reject) => { if (this._helper.hasPendingRequests() === false) {