From 728e69e74ce3971210cb3accd180cb85f4cbb80b Mon Sep 17 00:00:00 2001 From: Ana G <40721795+Bitcoinera@users.noreply.github.com> Date: Wed, 8 Jan 2020 13:28:01 +0100 Subject: [PATCH] delete perblockcachedatasource (#253) --- lib/source/PerBlockCacheDataSource.js | 28 --------------------------- 1 file changed, 28 deletions(-) delete mode 100644 lib/source/PerBlockCacheDataSource.js diff --git a/lib/source/PerBlockCacheDataSource.js b/lib/source/PerBlockCacheDataSource.js deleted file mode 100644 index 8b0f1fdfbd..0000000000 --- a/lib/source/PerBlockCacheDataSource.js +++ /dev/null @@ -1,28 +0,0 @@ -// HACK! Stupid Apollo doesn't support proper caching logic -// This appends the cache key of every request by the height so that every new block serves fresh data - -const { RESTDataSource } = require('apollo-datasource-rest') - -class PerBlockCacheDataSource extends RESTDataSource { - constructor() { - super() - this.cacheKey = 0 - } - - cacheKeyFor(request) { - return `${request.url}_${this.blockHeight}` - } - - clearMemory() { - // The memoizedResults map used for caching requests is never - // cleared automatically. The RESTDataSource assumes it will be - // created a new for each request. - // We maintain instances for parsing new block events on a network, - // so we have a need to call this manually. - this.memoizedResults.clear() - } -} - -module.exports = { - PerBlockCacheDataSource -}