Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
be8227f451 | |||
d8f526ef2d | |||
92b858e248 | |||
26511fc10e |
20
package-lock.json
generated
20
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/levelcache",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.6",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@ -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",
|
||||
|
11
package.json
11
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/levelcache",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.6",
|
||||
"private": false,
|
||||
"description": "a cache that uses memory/disk/s3 as backup",
|
||||
"main": "dist/index.js",
|
||||
@ -16,16 +16,17 @@
|
||||
"@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/smartstring": "^3.0.18"
|
||||
"@pushrocks/smartfile": "^7.0.8",
|
||||
"@pushrocks/smartstring": "^3.0.18",
|
||||
"@pushrocks/smartunique": "^3.0.1"
|
||||
},
|
||||
"files": [
|
||||
"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();
|
||||
|
@ -1,8 +1,6 @@
|
||||
import * as plugins from './levelcache.plugins';
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
export class CacheDiskManager {
|
||||
|
||||
}
|
||||
export class CacheDiskManager {}
|
||||
|
@ -1,5 +1,3 @@
|
||||
import * as plugins from './levelcache.plugins';
|
||||
|
||||
export class CacheMemoryManager {
|
||||
|
||||
}
|
||||
export class CacheMemoryManager {}
|
||||
|
@ -1,8 +1,6 @@
|
||||
import * as plugins from './levelcache.plugins';
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
export class CacheS3Manager {
|
||||
|
||||
}
|
||||
export class CacheS3Manager {}
|
||||
|
@ -1,5 +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;
|
||||
|
||||
constructor(optionsArg: {}) {}
|
||||
}
|
||||
|
21
ts/levelcache.classes.cacherouter.ts
Normal file
21
ts/levelcache.classes.cacherouter.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import * as plugins from './levelcache.plugins';
|
||||
import { LevelCache } from './levelcache.classes.levelcache';
|
||||
|
||||
export class CacheRouter {
|
||||
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() {}
|
||||
}
|
@ -2,41 +2,59 @@ import * as plugins from './levelcache.plugins';
|
||||
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();
|
||||
|
||||
public options: ILevelCacheConstructorOptions;
|
||||
|
||||
constructor(optionsArg: ILevelCacheConstructorOptions) {
|
||||
this.options = optionsArg;
|
||||
}
|
||||
|
||||
private processKey(keyArg: string) {
|
||||
if (!keyArg) {
|
||||
return plugins.smartunique.shortId();
|
||||
}
|
||||
}
|
||||
|
||||
// Blobs
|
||||
/**
|
||||
* store a Blob
|
||||
*/
|
||||
public async storeBlobByKey () {};
|
||||
public async storeBlobByKey(keyArg: string, blob: Buffer) {
|
||||
keyArg = this.processKey(keyArg);
|
||||
return keyArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* retrieve a blob
|
||||
*/
|
||||
public async retrieveBlob () {};
|
||||
|
||||
public async retrieveBlob(keyArg: string): CacheEntry {}
|
||||
|
||||
// Cache Entries
|
||||
/**
|
||||
* store a Cache Entries
|
||||
*/
|
||||
public async storeCacheEntry() {};
|
||||
|
||||
/**
|
||||
* retrieve cache entry
|
||||
*/
|
||||
public async retrieveCacheEntry () {};
|
||||
public async retrieveCacheEntryByKey(): CacheEntry {}
|
||||
|
||||
/**
|
||||
* cleans the cache
|
||||
*/
|
||||
public clean() {};
|
||||
public clean() {}
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
// node native scope
|
||||
import * as path from 'path';
|
||||
|
||||
export {
|
||||
path
|
||||
}
|
||||
export { path };
|
||||
|
||||
// @pushrocks scope
|
||||
import * as lik from '@pushrocks/lik';
|
||||
@ -11,11 +9,6 @@ import * as smartbucket from '@pushrocks/smartbucket';
|
||||
import * as smartcache from '@pushrocks/smartcache';
|
||||
import * as smartfile from '@pushrocks/smartfile';
|
||||
import * as smartstring from '@pushrocks/smartstring';
|
||||
import * as smartunique from '@pushrocks/smartunique';
|
||||
|
||||
export {
|
||||
lik,
|
||||
smartbucket,
|
||||
smartcache,
|
||||
smartfile,
|
||||
smartstring
|
||||
};
|
||||
export { lik, smartbucket, smartcache, smartfile, smartstring, smartunique };
|
||||
|
Reference in New Issue
Block a user