Skip to content

Commit f0156b0

Browse files
committed
Update stores to use data not responses, filesystem and memory tests work the same now
1 parent 4f43d85 commit f0156b0

File tree

5 files changed

+360
-228
lines changed

5 files changed

+360
-228
lines changed

lib/cacheism.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Cacheism.prototype.go = async function (cacheDomain, cachePath, status, callback
1717
let hasCache = await this.store.isset(name);
1818

1919
if (hasCache) {
20-
existing = await this.store.get(name);
20+
existing = (await this.store.get(name)).response();
2121
}
2222

2323
try {
@@ -46,7 +46,7 @@ Cacheism.prototype.go = async function (cacheDomain, cachePath, status, callback
4646

4747
}
4848

49-
await this.store.set(response);
49+
await this.store.set(common.Data.fromResponse(response));
5050

5151
Object.freeze(response);
5252
return response;

lib/store-filesystem.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ module.exports = function (config) {
1616
storeFilesystem.get = async (cacheName) => {
1717
const filename = path.resolve(config.datadir, `${cacheName}.json`);
1818
const data = await fsPromises.readFile(filename, 'utf8');
19-
return common.Data.parse(data).response();
19+
return common.Data.parse(data);
2020
}
2121

22-
storeFilesystem.set = async (hit) => {
23-
const filename = path.resolve(config.datadir, `${hit.cacheName}.json`);
22+
storeFilesystem.set = async (data) => {
23+
const filename = path.resolve(config.datadir, `${data.cacheName}.json`);
2424
_mkdir(path.dirname(filename));
25-
await fsPromises.writeFile(filename, common.Data.fromResponse(hit).stringify(), 'utf8');
25+
await fsPromises.writeFile(filename, data.stringify(), 'utf8');
2626
}
2727

2828
storeFilesystem.isset = async (cacheName) => {

lib/store-memory.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ module.exports = function (config) {
44
const storeMemory = { data: {} };
55

66
storeMemory.get = async (cacheName) => {
7-
return common.Data.parse(storeMemory.data[cacheName]).response();
7+
return common.Data.parse(storeMemory.data[cacheName]);
88
}
99

10-
storeMemory.set = async (hit) => {
11-
storeMemory.data[hit.cacheName] = common.Data.fromResponse(hit).stringify();
10+
storeMemory.set = async (data) => {
11+
storeMemory.data[data.cacheName] = data.stringify();
1212
}
1313

1414
storeMemory.isset = async (cacheName) => {

0 commit comments

Comments
 (0)