61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
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 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(keyArg: string, blob: Buffer) {
|
|
keyArg = this.processKey(keyArg);
|
|
return keyArg;
|
|
}
|
|
|
|
/**
|
|
* retrieve a blob
|
|
*/
|
|
public async retrieveBlob(keyArg: string): CacheEntry {}
|
|
|
|
// Cache Entries
|
|
/**
|
|
* retrieve cache entry
|
|
*/
|
|
public async retrieveCacheEntryByKey(): CacheEntry {}
|
|
|
|
/**
|
|
* cleans the cache
|
|
*/
|
|
public clean() {}
|
|
}
|