This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -278,42 +278,42 @@ declare class NodeCache extends events.EventEmitter {
* it to a serialized JSON
* @param ttl The time to live in seconds.
*/
set<T>(
set<T extends ValueType>(
key: Key,
value: T,
value: ValueType extends unknown ? T : ValueType,
ttl: number | string
): boolean;
set<T>(
set<T extends ValueType>(
key: Key,
value: T
value: ValueType extends unknown ? T : ValueType
): boolean;
/**
* in the event of a cache miss (no value is assinged to given cache key), value will be written to cache and returned. In case of cache hit, cached value will be returned without executing given value. If the given value is type of `Function`, it will be executed and returned result will be fetched
*
*
* @param key cache key
* @param ttl The time to live in seconds.
* @param value function that returns a value to be stored in cache, or the value itself
*/
fetch<T>(
fetch<T extends ValueType>(
key: Key,
ttl: number | string,
value: () => T,
): T;
value: () => ValueType extends unknown ? T : ValueType,
): ValueType extends unknown ? T : ValueType;
fetch<T>(
fetch<T extends ValueType>(
key: Key,
value: () => T,
): T;
value: () => ValueType extends unknown ? T : ValueType,
): ValueType extends unknown ? T : ValueType;
/**
* set multiple cached keys at once and change the stats
*
* @param keyValueSet an array of object which includes key,value and ttl
*/
mset<T>(
keyValueSet: ValueSetItem<T>[]
mset<T extends ValueType>(
keyValueSet: ValueSetItem<ValueType extends unknown ? T : ValueType>[]
): boolean;
/**
Expand All
@@ -334,10 +334,9 @@ declare class NodeCache extends events.EventEmitter {
* @param key cache key
* @returns The value stored in the key
*/
take<T>(
take<T extends ValueType>(
key: Key
): T | undefined;
): (ValueType extends unknown ? T : ValueType) | undefined;
/**
* reset or redefine the ttl of a key. If `ttl` is not passed or set to 0 it's similar to `.del()`
*/
Expand Down
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change types to allow setting value type on the class #315
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Change types to allow setting value type on the class #315
Filter by extension
Viewed files
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing