Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
be8227f451 | |||
d8f526ef2d | |||
92b858e248 | |||
26511fc10e | |||
1cdba38408 | |||
7a0525bd1f |
20
package-lock.json
generated
20
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/levelcache",
|
"name": "@pushrocks/levelcache",
|
||||||
"version": "1.0.3",
|
"version": "1.0.6",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -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",
|
||||||
|
11
package.json
11
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/levelcache",
|
"name": "@pushrocks/levelcache",
|
||||||
"version": "1.0.3",
|
"version": "1.0.6",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a cache that uses memory/disk/s3 as backup",
|
"description": "a cache that uses memory/disk/s3 as backup",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@ -16,16 +16,17 @@
|
|||||||
"@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"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
13
test/test.ts
13
test/test.ts
@ -1,8 +1,17 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as levelcache from '../ts/index';
|
import * as levelcache from '../ts/index';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
let testLevelCache: levelcache.LevelCache;
|
||||||
console.log('hi');
|
|
||||||
|
tap.test('should create a new levelcache instance', async () => {
|
||||||
|
testLevelCache = new levelcache.LevelCache({
|
||||||
|
|
||||||
|
});
|
||||||
|
expect(testLevelCache).to.be.instanceOf(levelcache.LevelCache);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should cache a value', async () => {
|
||||||
|
testLevelCache.
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
6
ts/levelcache.classes.cache.diskmanager.ts
Normal file
6
ts/levelcache.classes.cache.diskmanager.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import * as plugins from './levelcache.plugins';
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export class CacheDiskManager {}
|
3
ts/levelcache.classes.cache.memorymanager.ts
Normal file
3
ts/levelcache.classes.cache.memorymanager.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import * as plugins from './levelcache.plugins';
|
||||||
|
|
||||||
|
export class CacheMemoryManager {}
|
6
ts/levelcache.classes.cache.s3manager.ts
Normal file
6
ts/levelcache.classes.cache.s3manager.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import * as plugins from './levelcache.plugins';
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export class CacheS3Manager {}
|
@ -1 +1,20 @@
|
|||||||
import * as plugins from './levelcache.plugins';
|
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() {}
|
||||||
|
}
|
@ -1,29 +1,60 @@
|
|||||||
import * as plugins from './levelcache.plugins';
|
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
|
* 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 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
|
// Blobs
|
||||||
/**
|
/**
|
||||||
* store a Blob
|
* store a Blob
|
||||||
*/
|
*/
|
||||||
public async storeBlob () {};
|
public async storeBlobByKey(keyArg: string, blob: Buffer) {
|
||||||
|
keyArg = this.processKey(keyArg);
|
||||||
|
return keyArg;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retrieve a blob
|
* retrieve a blob
|
||||||
*/
|
*/
|
||||||
public async retrieveBlob () {};
|
public async retrieveBlob(keyArg: string): CacheEntry {}
|
||||||
|
|
||||||
|
// Cache Entries
|
||||||
// Cachen Entries
|
|
||||||
/**
|
/**
|
||||||
* store a Cache Entries
|
* retrieve cache entry
|
||||||
*/
|
*/
|
||||||
public async storeCacheEntry() {};
|
public async retrieveCacheEntryByKey(): CacheEntry {}
|
||||||
public async retrieveCacheEntry () {};
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cleans the cache
|
||||||
|
*/
|
||||||
public clean() {}
|
public clean() {}
|
||||||
}
|
}
|
||||||
|
@ -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';
|
||||||
@ -11,11 +9,6 @@ import * as smartbucket from '@pushrocks/smartbucket';
|
|||||||
import * as smartcache from '@pushrocks/smartcache';
|
import * as smartcache from '@pushrocks/smartcache';
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
import * as smartstring from '@pushrocks/smartstring';
|
import * as smartstring from '@pushrocks/smartstring';
|
||||||
|
import * as smartunique from '@pushrocks/smartunique';
|
||||||
|
|
||||||
export {
|
export { lik, smartbucket, smartcache, smartfile, smartstring, smartunique };
|
||||||
lik,
|
|
||||||
smartbucket,
|
|
||||||
smartcache,
|
|
||||||
smartfile,
|
|
||||||
smartstring
|
|
||||||
};
|
|
||||||
|
Reference in New Issue
Block a user