Skip to content

Commit 9c15073

Browse files
authored
Merge pull request #4 from adamjosefus/development
Development
2 parents 72d7d45 + 1668128 commit 9c15073

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ cache.has(cacheKey); // -> boolean
4747

4848
## Documentation 📖
4949

50-
Description of all classes and methods with **examples** will found in the [documentation](https://doc.deno.land/https://deno.land/x/allo_caching@v1.0.1/mod.ts).
50+
Description of all classes and methods with **examples** will found in the [documentation](https://doc.deno.land/https://raw.githubusercontent.com/adamjosefus/allo_caching/main/mod.ts).
5151

5252
---
5353

Diff for: libs/Cache.ts

+19
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export class Cache<T> {
1414
readonly #storage: Map<string, T> = new Map();
1515

1616

17+
/**
18+
* @param `key` Cache key.
19+
* @param `generator` Generator generates a value if it is not loaded.
20+
* @returns `<T>` or `<T> | undefined` – depending on whether the generator has been set.
21+
*/
1722
load<E extends LoadEntryType<T>>(...args: E): E extends LoadAndGenerateEntryType<T> ? T : T | undefined {
1823
const [key, generator] = args;
1924

@@ -33,16 +38,30 @@ export class Cache<T> {
3338
}
3439

3540

41+
/**
42+
* Save value to cache by key.
43+
* @param key
44+
* @param value
45+
*/
3646
save(key: string, value: T): void {
3747
this.#storage.set(key, value);
3848
}
3949

4050

51+
/**
52+
* Check if value exists in cache.
53+
* @param key
54+
* @param value
55+
*/
4156
has(key: string): boolean {
4257
return this.#storage.has(key);
4358
}
4459

4560

61+
/**
62+
* Delete value from cache.
63+
* @param key
64+
*/
4665
delete(key: string): void {
4766
this.#storage.delete(key);
4867
}

0 commit comments

Comments
 (0)