diff --git a/package-lock.json b/package-lock.json index dbc28e4..e9e8c47 100644 --- a/package-lock.json +++ b/package-lock.json @@ -98,9 +98,9 @@ } }, "@pushrocks/lik": { - "version": "3.0.16", - "resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.16.tgz", - "integrity": "sha512-rvF4aJL6IRDZXNtSHwnkT+iXUj4peY928g7xpJh8hrFxABMbE89nH/fOBQ0m36IuI5dZBvbZv++2qiFOLsL+oA==", + "version": "3.0.18", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.18.tgz", + "integrity": "sha512-H/6yN9Ci0lIRvv8klOwNtLid9v+Owjk0ehumHLfOUkEUklJPbgSDOli+DlWbyO80RBGtQJyHR5xjOMnnaBzOhg==", "requires": { "@pushrocks/smartdelay": "^2.0.6", "@pushrocks/smartpromise": "^3.0.6", @@ -214,9 +214,9 @@ } }, "@pushrocks/smartfile": { - "version": "7.0.6", - "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.6.tgz", - "integrity": "sha512-X1kWg1HSQ/MqasRIHPCf6D9CRrcIrpTjW8KLc4GkApJ/W/IVaKsQkJQfdimlg1uc/9v8AYnoRdiGa51yxyghZA==", + "version": "7.0.8", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.8.tgz", + "integrity": "sha512-cNxTs+vyuegAV7HayoobQIAbO4j+XEMoEl9nbnehHhmxdt26/Gin6+eqWn/5/OEJj5EggrrZftFJQMzdJ50dDQ==", "requires": { "@pushrocks/smarthash": "^2.0.6", "@pushrocks/smartpath": "^4.0.1", @@ -480,9 +480,9 @@ } }, "@types/node": { - "version": "13.7.0", - "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-13.7.0.tgz", - "integrity": "sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ==" + "version": "13.7.1", + "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-13.7.1.tgz", + "integrity": "sha512-Zq8gcQGmn4txQEJeiXo/KiLpon8TzAl0kmKH4zdWctPj05nWwp1ClMdAVEloqrQKfaC48PNLdgN/aVaLqUrluA==" }, "@types/shortid": { "version": "0.0.29", diff --git a/package.json b/package.json index fb8ffec..8283547 100644 --- a/package.json +++ b/package.json @@ -16,15 +16,15 @@ "@gitzone/tsbuild": "^2.0.22", "@gitzone/tstest": "^1.0.15", "@pushrocks/tapbundle": "^3.0.7", - "@types/node": "^13.7.0", + "@types/node": "^13.7.1", "tslint": "^6.0.0", "tslint-config-prettier": "^1.15.0" }, "dependencies": { - "@pushrocks/lik": "^3.0.16", + "@pushrocks/lik": "^3.0.18", "@pushrocks/smartbucket": "^1.0.24", "@pushrocks/smartcache": "^1.0.13", - "@pushrocks/smartfile": "^7.0.6", + "@pushrocks/smartfile": "^7.0.8", "@pushrocks/smartstring": "^3.0.18", "@pushrocks/smartunique": "^3.0.1" }, @@ -39,4 +39,4 @@ "npmextra.json", "readme.md" ] -} +} \ No newline at end of file diff --git a/test/test.ts b/test/test.ts index eef47a4..9eae5f5 100644 --- a/test/test.ts +++ b/test/test.ts @@ -4,12 +4,14 @@ import * as levelcache from '../ts/index'; let testLevelCache: levelcache.LevelCache; tap.test('should create a new levelcache instance', async () => { - testLevelCache = new levelcache.LevelCache(); + testLevelCache = new levelcache.LevelCache({ + + }); expect(testLevelCache).to.be.instanceOf(levelcache.LevelCache); }); tap.test('should cache a value', async () => { - + testLevelCache. }); tap.start(); diff --git a/ts/levelcache.classes.cache.diskmanager.ts b/ts/levelcache.classes.cache.diskmanager.ts index 51824a1..f97363e 100644 --- a/ts/levelcache.classes.cache.diskmanager.ts +++ b/ts/levelcache.classes.cache.diskmanager.ts @@ -1,8 +1,6 @@ import * as plugins from './levelcache.plugins'; /** - * + * */ -export class CacheDiskManager { - -} \ No newline at end of file +export class CacheDiskManager {} diff --git a/ts/levelcache.classes.cache.memorymanager.ts b/ts/levelcache.classes.cache.memorymanager.ts index 8ae883c..6e65200 100644 --- a/ts/levelcache.classes.cache.memorymanager.ts +++ b/ts/levelcache.classes.cache.memorymanager.ts @@ -1,5 +1,3 @@ import * as plugins from './levelcache.plugins'; -export class CacheMemoryManager { - -} \ No newline at end of file +export class CacheMemoryManager {} diff --git a/ts/levelcache.classes.cache.s3manager.ts b/ts/levelcache.classes.cache.s3manager.ts index f4e3186..4cd86c9 100644 --- a/ts/levelcache.classes.cache.s3manager.ts +++ b/ts/levelcache.classes.cache.s3manager.ts @@ -1,8 +1,6 @@ import * as plugins from './levelcache.plugins'; /** - * + * */ -export class CacheS3Manager { - -} \ No newline at end of file +export class CacheS3Manager {} diff --git a/ts/levelcache.classes.cacheentry.ts b/ts/levelcache.classes.cacheentry.ts index e5ec00b..d4882bb 100644 --- a/ts/levelcache.classes.cacheentry.ts +++ b/ts/levelcache.classes.cacheentry.ts @@ -1,10 +1,20 @@ import * as plugins from './levelcache.plugins'; +export interface ICacheEntryConstructorOptions {} + +/** + * a CacheEntry + */ export class CacheEntry { + public static fromBuffer() {} + public static fromString() {} + type: 'string' | 'blob'; mode: 'complete' | 'stream'; keyArg: string; cacheStream: ReadableStream; cacheContents: Buffer; cacheValue: string; -} \ No newline at end of file + + constructor(optionsArg: {}) {} +} diff --git a/ts/levelcache.classes.cacherouter.ts b/ts/levelcache.classes.cacherouter.ts index 3da457d..76b6080 100644 --- a/ts/levelcache.classes.cacherouter.ts +++ b/ts/levelcache.classes.cacherouter.ts @@ -1,6 +1,21 @@ import * as plugins from './levelcache.plugins'; +import { LevelCache } from './levelcache.classes.levelcache'; export class CacheRouter { - async routeStoreAction() {} - async routeRetrieveAction() {} -} \ No newline at end of file + public levelCacheRef: LevelCache; + public cacheMap; + + constructor(levelCacheRef: LevelCache) { + this.levelCacheRef = levelCacheRef; + } + + /** + * gets the relevant cache to perform a store action on + */ + async getCacheForStoreAction() {} + + /** + * gets the relevant cache to perform a retrieval action on + */ + async getCacheForRetrieveAction() {} +} diff --git a/ts/levelcache.classes.levelcache.ts b/ts/levelcache.classes.levelcache.ts index 67d3ba7..8849d71 100644 --- a/ts/levelcache.classes.levelcache.ts +++ b/ts/levelcache.classes.levelcache.ts @@ -3,17 +3,31 @@ import { CacheDiskManager } from './levelcache.classes.cache.diskmanager'; import { CacheMemoryManager } from './levelcache.classes.cache.memorymanager'; import { CacheS3Manager } from './levelcache.classes.cache.s3manager'; import { CacheEntry } from './levelcache.classes.cacheentry'; +import { CacheRouter } from './levelcache.classes.cacherouter'; + +export interface ILevelCacheConstructorOptions { + maxMemoryStorageInMB: number; + maxDiskStorageInMB: number; + maxS3StorageInMB?: number; + smartbucketConfig?: plugins.smartbucket.ISmartBucketConfig; +} /** * a leveled cache for storing things for a short time */ export class LevelCache { - public cacheMap = new plugins.lik.Objectmap(); + public cacheRouter = new CacheRouter(this); public cacheDiskManager = new CacheDiskManager(); public cacheMemoryManager = new CacheMemoryManager(); public cacheS3Manager = new CacheS3Manager(); - private processKey (keyArg: string) { + public options: ILevelCacheConstructorOptions; + + constructor(optionsArg: ILevelCacheConstructorOptions) { + this.options = optionsArg; + } + + private processKey(keyArg: string) { if (!keyArg) { return plugins.smartunique.shortId(); } @@ -23,7 +37,7 @@ export class LevelCache { /** * store a Blob */ - public async storeBlobByKey (keyArg: string, blob: Buffer) { + public async storeBlobByKey(keyArg: string, blob: Buffer) { keyArg = this.processKey(keyArg); return keyArg; } @@ -31,30 +45,16 @@ export class LevelCache { /** * retrieve a blob */ - public async retrieveBlob (keyArg: string): CacheEntry { - - } - + public async retrieveBlob(keyArg: string): CacheEntry {} // Cache Entries - /** - * store a Cache Entries - */ - public async storeCacheEntry(cacheEntryArg: CacheEntry): string { - - } - /** * retrieve cache entry */ - public async retrieveCacheEntry (): CacheEntry { - - } + public async retrieveCacheEntryByKey(): CacheEntry {} /** * cleans the cache */ - public clean() { - - }; + public clean() {} } diff --git a/ts/levelcache.plugins.ts b/ts/levelcache.plugins.ts index 7186112..9c2feb0 100644 --- a/ts/levelcache.plugins.ts +++ b/ts/levelcache.plugins.ts @@ -1,9 +1,7 @@ // node native scope import * as path from 'path'; -export { - path -} +export { path }; // @pushrocks scope import * as lik from '@pushrocks/lik'; @@ -13,11 +11,4 @@ import * as smartfile from '@pushrocks/smartfile'; import * as smartstring from '@pushrocks/smartstring'; import * as smartunique from '@pushrocks/smartunique'; -export { - lik, - smartbucket, - smartcache, - smartfile, - smartstring, - smartunique -}; +export { lik, smartbucket, smartcache, smartfile, smartstring, smartunique };