-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
32 lines (25 loc) · 860 Bytes
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import {Signal} from 'signals'
export interface CacheOptions {
dependencies?: CacheDependency | CacheDependency[]
slidingExpirationMsec?: number
absoluteExpiration?: Date | ((options: CacheOptions) => Date)
removeCallback?: (key: string, value, reason: string) => any
}
export default class Cache {
maxSize: number
size: number
itemRemoved: Signal
constructor(maxSize: number)
set(key, value, options?: CacheOptions): void
get(key)
has(key: any | any[]): boolean
remove(key: any | any[], reason?: string): void
clear(testFn?: (key, value) => boolean): number
enumerate(fn: (key, data) => boolean): void
}
export class CacheDependency {
triggered: Signal
constructor(keys: any | any[], dependencies: CacheDependency | CacheDependency[])
isTriggered(): boolean
getLastModified(): Date
}