fix(core): update

This commit is contained in:
Philipp Kunz 2020-02-15 22:38:28 +00:00
parent 92b858e248
commit d8f526ef2d
10 changed files with 73 additions and 61 deletions

18
package-lock.json generated
View File

@ -98,9 +98,9 @@
} }
}, },
"@pushrocks/lik": { "@pushrocks/lik": {
"version": "3.0.16", "version": "3.0.18",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.16.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.18.tgz",
"integrity": "sha512-rvF4aJL6IRDZXNtSHwnkT+iXUj4peY928g7xpJh8hrFxABMbE89nH/fOBQ0m36IuI5dZBvbZv++2qiFOLsL+oA==", "integrity": "sha512-H/6yN9Ci0lIRvv8klOwNtLid9v+Owjk0ehumHLfOUkEUklJPbgSDOli+DlWbyO80RBGtQJyHR5xjOMnnaBzOhg==",
"requires": { "requires": {
"@pushrocks/smartdelay": "^2.0.6", "@pushrocks/smartdelay": "^2.0.6",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^3.0.6",
@ -214,9 +214,9 @@
} }
}, },
"@pushrocks/smartfile": { "@pushrocks/smartfile": {
"version": "7.0.6", "version": "7.0.8",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.6.tgz", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.8.tgz",
"integrity": "sha512-X1kWg1HSQ/MqasRIHPCf6D9CRrcIrpTjW8KLc4GkApJ/W/IVaKsQkJQfdimlg1uc/9v8AYnoRdiGa51yxyghZA==", "integrity": "sha512-cNxTs+vyuegAV7HayoobQIAbO4j+XEMoEl9nbnehHhmxdt26/Gin6+eqWn/5/OEJj5EggrrZftFJQMzdJ50dDQ==",
"requires": { "requires": {
"@pushrocks/smarthash": "^2.0.6", "@pushrocks/smarthash": "^2.0.6",
"@pushrocks/smartpath": "^4.0.1", "@pushrocks/smartpath": "^4.0.1",
@ -480,9 +480,9 @@
} }
}, },
"@types/node": { "@types/node": {
"version": "13.7.0", "version": "13.7.1",
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-13.7.0.tgz", "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-13.7.1.tgz",
"integrity": "sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ==" "integrity": "sha512-Zq8gcQGmn4txQEJeiXo/KiLpon8TzAl0kmKH4zdWctPj05nWwp1ClMdAVEloqrQKfaC48PNLdgN/aVaLqUrluA=="
}, },
"@types/shortid": { "@types/shortid": {
"version": "0.0.29", "version": "0.0.29",

View File

@ -16,15 +16,15 @@
"@gitzone/tsbuild": "^2.0.22", "@gitzone/tsbuild": "^2.0.22",
"@gitzone/tstest": "^1.0.15", "@gitzone/tstest": "^1.0.15",
"@pushrocks/tapbundle": "^3.0.7", "@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^13.7.0", "@types/node": "^13.7.1",
"tslint": "^6.0.0", "tslint": "^6.0.0",
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/lik": "^3.0.16", "@pushrocks/lik": "^3.0.18",
"@pushrocks/smartbucket": "^1.0.24", "@pushrocks/smartbucket": "^1.0.24",
"@pushrocks/smartcache": "^1.0.13", "@pushrocks/smartcache": "^1.0.13",
"@pushrocks/smartfile": "^7.0.6", "@pushrocks/smartfile": "^7.0.8",
"@pushrocks/smartstring": "^3.0.18", "@pushrocks/smartstring": "^3.0.18",
"@pushrocks/smartunique": "^3.0.1" "@pushrocks/smartunique": "^3.0.1"
}, },
@ -39,4 +39,4 @@
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
] ]
} }

View File

@ -4,12 +4,14 @@ import * as levelcache from '../ts/index';
let testLevelCache: levelcache.LevelCache; let testLevelCache: levelcache.LevelCache;
tap.test('should create a new levelcache instance', async () => { tap.test('should create a new levelcache instance', async () => {
testLevelCache = new levelcache.LevelCache(); testLevelCache = new levelcache.LevelCache({
});
expect(testLevelCache).to.be.instanceOf(levelcache.LevelCache); expect(testLevelCache).to.be.instanceOf(levelcache.LevelCache);
}); });
tap.test('should cache a value', async () => { tap.test('should cache a value', async () => {
testLevelCache.
}); });
tap.start(); tap.start();

View File

@ -1,8 +1,6 @@
import * as plugins from './levelcache.plugins'; import * as plugins from './levelcache.plugins';
/** /**
* *
*/ */
export class CacheDiskManager { export class CacheDiskManager {}
}

View File

@ -1,5 +1,3 @@
import * as plugins from './levelcache.plugins'; import * as plugins from './levelcache.plugins';
export class CacheMemoryManager { export class CacheMemoryManager {}
}

View File

@ -1,8 +1,6 @@
import * as plugins from './levelcache.plugins'; import * as plugins from './levelcache.plugins';
/** /**
* *
*/ */
export class CacheS3Manager { export class CacheS3Manager {}
}

View File

@ -1,10 +1,20 @@
import * as plugins from './levelcache.plugins'; import * as plugins from './levelcache.plugins';
export interface ICacheEntryConstructorOptions {}
/**
* a CacheEntry
*/
export class CacheEntry { export class CacheEntry {
public static fromBuffer() {}
public static fromString() {}
type: 'string' | 'blob'; type: 'string' | 'blob';
mode: 'complete' | 'stream'; mode: 'complete' | 'stream';
keyArg: string; keyArg: string;
cacheStream: ReadableStream; cacheStream: ReadableStream;
cacheContents: Buffer; cacheContents: Buffer;
cacheValue: string; cacheValue: string;
}
constructor(optionsArg: {}) {}
}

View File

@ -1,6 +1,21 @@
import * as plugins from './levelcache.plugins'; import * as plugins from './levelcache.plugins';
import { LevelCache } from './levelcache.classes.levelcache';
export class CacheRouter { export class CacheRouter {
async routeStoreAction() {} public levelCacheRef: LevelCache;
async routeRetrieveAction() {} 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() {}
}

View File

@ -3,17 +3,31 @@ import { CacheDiskManager } from './levelcache.classes.cache.diskmanager';
import { CacheMemoryManager } from './levelcache.classes.cache.memorymanager'; import { CacheMemoryManager } from './levelcache.classes.cache.memorymanager';
import { CacheS3Manager } from './levelcache.classes.cache.s3manager'; import { CacheS3Manager } from './levelcache.classes.cache.s3manager';
import { CacheEntry } from './levelcache.classes.cacheentry'; 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 * a leveled cache for storing things for a short time
*/ */
export class LevelCache { export class LevelCache {
public cacheMap = new plugins.lik.Objectmap(); public cacheRouter = new CacheRouter(this);
public cacheDiskManager = new CacheDiskManager(); public cacheDiskManager = new CacheDiskManager();
public cacheMemoryManager = new CacheMemoryManager(); public cacheMemoryManager = new CacheMemoryManager();
public cacheS3Manager = new CacheS3Manager(); public cacheS3Manager = new CacheS3Manager();
private processKey (keyArg: string) { public options: ILevelCacheConstructorOptions;
constructor(optionsArg: ILevelCacheConstructorOptions) {
this.options = optionsArg;
}
private processKey(keyArg: string) {
if (!keyArg) { if (!keyArg) {
return plugins.smartunique.shortId(); return plugins.smartunique.shortId();
} }
@ -23,7 +37,7 @@ export class LevelCache {
/** /**
* store a Blob * store a Blob
*/ */
public async storeBlobByKey (keyArg: string, blob: Buffer) { public async storeBlobByKey(keyArg: string, blob: Buffer) {
keyArg = this.processKey(keyArg); keyArg = this.processKey(keyArg);
return keyArg; return keyArg;
} }
@ -31,30 +45,16 @@ export class LevelCache {
/** /**
* retrieve a blob * retrieve a blob
*/ */
public async retrieveBlob (keyArg: string): CacheEntry { public async retrieveBlob(keyArg: string): CacheEntry {}
}
// Cache Entries // Cache Entries
/**
* store a Cache Entries
*/
public async storeCacheEntry(cacheEntryArg: CacheEntry): string {
}
/** /**
* retrieve cache entry * retrieve cache entry
*/ */
public async retrieveCacheEntry (): CacheEntry { public async retrieveCacheEntryByKey(): CacheEntry {}
}
/** /**
* cleans the cache * cleans the cache
*/ */
public clean() { public clean() {}
};
} }

View File

@ -1,9 +1,7 @@
// node native scope // node native scope
import * as path from 'path'; import * as path from 'path';
export { export { path };
path
}
// @pushrocks scope // @pushrocks scope
import * as lik from '@pushrocks/lik'; import * as lik from '@pushrocks/lik';
@ -13,11 +11,4 @@ import * as smartfile from '@pushrocks/smartfile';
import * as smartstring from '@pushrocks/smartstring'; import * as smartstring from '@pushrocks/smartstring';
import * as smartunique from '@pushrocks/smartunique'; import * as smartunique from '@pushrocks/smartunique';
export { export { lik, smartbucket, smartcache, smartfile, smartstring, smartunique };
lik,
smartbucket,
smartcache,
smartfile,
smartstring,
smartunique
};