/*! * Copyright (c) 2020 Ville de Montreal. All rights reserved. * Licensed under the MIT license. * See LICENSE file in the project root for full license information. */ import { ITimeProvider } from '../time/ITimeProvider'; /** * A simple generic cache implementation that can expire entries using a ttl. * Note that the ttl cleanup will happen only when modifying the cache, * but not when reading entries. */ export declare class Cache { private readonly timeProvider; private readonly entries; /** * Creates a new instance of a Cache * @param timeProvider the time provider used to know when the ttl expires. */ constructor(timeProvider: ITimeProvider); /** * finds an entry in the cache * @param key the key used to find the entry * @returns either the associated value or undefined. */ get(key: string): T | undefined; /** * add or edit a cache entry * @param key the key used to store the value * @param value the value associated to the key * @param ttl a number of seconds to keep the value available */ set(key: string, value: T, ttl: number): void; /** * delete an existing cache entry. * Note that it is safe to delete an entry that doesn't exist. * @param key the key used to find and delete the entry */ delete(key: string): void; private hasExpired; private deleteExpiredEntries; }