@linkedmink/multilevel-aging-cache-mongoose
Version:
Package implements Mongoose for @linkedmink/multilevel-aging-cache
47 lines • 1.86 kB
TypeScript
import { Document, Model, Types } from 'mongoose';
import { IAgedValue, IStorageProvider } from '@linkedmink/multilevel-aging-cache';
import { IMongooseProviderOptions } from './IMongooseProviderOptions';
/**
* Use mongodb as a persistent storage mechanism with Mongoose documents
*/
export declare class MongooseProvider<TKey = Types.ObjectId, TValue extends Document = Document> implements IStorageProvider<TKey, TValue> {
private readonly model;
private readonly options;
readonly isPersistable = true;
private readonly logger;
private readonly keyProperty;
/**
* @param model The object returned by 'mongoose'.model function
* @param options Configuration for this data provider
*/
constructor(model: Model<TValue>, options: IMongooseProviderOptions<TKey, TValue>);
/**
* @param key The key to retrieve
* @returns The value if retreiving was successful or null
*/
get(key: TKey): Promise<IAgedValue<TValue> | null>;
/**
* @param key The key to set
* @param value The value to set
* @returns The value written if successful or null
*/
set(key: TKey, value: IAgedValue<TValue>): Promise<IAgedValue<TValue> | null>;
/**
* @param key The key to the value to delete
* @returns The value deleted or boolean (value | true is success). A provider
* is not required to return a value
*/
delete(key: TKey): Promise<IAgedValue<TValue> | boolean>;
/**
* @returns The keys that are currently available in the provider
*/
keys(): Promise<TKey[]>;
/**
* @returns The number of elements in this storage system
*/
size(): Promise<number>;
private updateRecordAge;
private getAgedValue;
private execIgnoreError;
}
//# sourceMappingURL=MongooseProvider.d.ts.map