UNPKG

@leyyo/cache

Version:
51 lines (50 loc) 4.22 kB
import { FieldId, FieldIddArray, FieldMap, FieldTupleArray, FieldValue, Id, KeyAny, TR } from "../types"; import { CacheHash, CacheHashDef, CacheHashSecure, CmdHashGetTimestamp, CmdHashGetTtl, CmdHashSetTimestamp, CmdHashSetTtl } from "./types"; import { CacheInvalidator, CacheInvalidatorResult } from "../invalidator"; import { CacheFormat } from "../format"; import { CacheChannel, CacheChannelProp, CacheChannelPropSecure } from "../channel"; import { ExpiryMode } from "../literal"; import { CacheResultBoolean, CacheResultGetExpiry, CacheResultNumber, CacheResultPersist, CacheResultSetExpiry } from "../command"; export declare abstract class CacheHashAbstract<A extends TR, N extends Id> implements CacheHash<A, N>, CacheHashSecure<A, N> { protected readonly channel: CacheChannel<A, N>; protected format: CacheFormat<A, N>; protected invalidator: CacheInvalidator<A>; protected prop: Readonly<CacheChannelProp<A>>; protected check: CacheChannelPropSecure<A>; protected constructor(channel: CacheChannel<A, N>); private _formatRawValue; private _formatRawValues; delete(key: KeyAny, fields: FieldIddArray<A>): Promise<CacheInvalidatorResult<A, CacheResultNumber>>; exists(key: KeyAny, field: FieldId<A>): Promise<CacheInvalidatorResult<A, CacheResultBoolean>>; existMore(key: KeyAny, fields: FieldIddArray<A>): Promise<CacheInvalidatorResult<A, Array<CacheResultBoolean>>>; getLength(key: KeyAny): Promise<CacheInvalidatorResult<A, CacheResultNumber>>; listFields(key: KeyAny): Promise<CacheInvalidatorResult<A, FieldIddArray<A>>>; getAll(key: KeyAny): Promise<CacheInvalidatorResult<A, Record<string, string>>>; getMore(key: KeyAny, fields: FieldIddArray<A>): Promise<CacheInvalidatorResult<A, Record<string, string>>>; getValue(key: KeyAny, field: FieldId<A>): Promise<CacheInvalidatorResult<A, string>>; setValue(key: KeyAny, field: FieldId<A>, value: FieldValue<A>): Promise<CacheInvalidatorResult<A, CacheResultNumber>>; setValuesMore(key: KeyAny, doc: Partial<A> | FieldMap<A> | FieldTupleArray<A>): Promise<CacheInvalidatorResult<A, CacheResultNumber>>; getTimestamp(key: KeyAny, fields: FieldIddArray<A>, opt?: CmdHashGetTimestamp): Promise<CacheInvalidatorResult<A, Record<string, CacheResultGetExpiry>>>; getTtl(key: KeyAny, fields: FieldIddArray<A>, opt?: CmdHashGetTtl): Promise<CacheInvalidatorResult<A, Record<string, CacheResultGetExpiry>>>; setTimestamp(key: KeyAny, fields: FieldIddArray<A>, opt?: CmdHashSetTimestamp): Promise<CacheInvalidatorResult<A, Record<string, CacheResultSetExpiry>>>; setTtl(key: KeyAny, fields: FieldIddArray<A>, opt?: CmdHashSetTtl): Promise<CacheInvalidatorResult<A, Record<string, CacheResultSetExpiry>>>; persist(key: KeyAny, fields: FieldIddArray<A>): Promise<CacheInvalidatorResult<A, Record<string, CacheResultPersist>>>; get $flat(): CacheHashDef; get $secure(): CacheHashSecure<A, N>; get $back(): CacheHash<A, N>; $init(): void; abstract $delete(key: string, fields: Array<string>): Promise<number>; abstract $exists(key: string, field: string): Promise<boolean>; abstract $existsMore(key: string, fields: Array<string>): Promise<Record<string, boolean>>; abstract $fields(key: string): Promise<Array<string>>; abstract $getOne(key: string, field: string): Promise<string>; abstract $get(key: string, fields: Array<string>): Promise<Array<string>>; abstract $getAll(key: string): Promise<Record<string, string>>; abstract $length(key: string): Promise<number>; abstract $set(key: string, record: Record<string, string>): Promise<number>; abstract $getTimestamp(key: string, fields: Array<string>): Promise<Array<CacheResultGetExpiry>>; abstract $setTimestamp(key: string, fields: Array<string>, milliseconds: number, mode?: ExpiryMode): Promise<Array<CacheResultSetExpiry>>; abstract $getTtl(key: string, fields: Array<string>): Promise<Array<CacheResultGetExpiry>>; abstract $setTtl(key: string, fields: Array<string>, milliseconds: number, mode?: ExpiryMode): Promise<Array<CacheResultSetExpiry>>; abstract $persist(key: string, fields: Array<string>): Promise<Array<CacheResultPersist>>; }