• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tabkram / execution-engine / 14140261552

29 Mar 2025 12:30AM UTC coverage: 91.94%. First build
14140261552

Pull #65

github

web-flow
Merge d6156fe1f into 2cd973999
Pull Request #65: feat: add cache decorator

232 of 268 branches covered (86.57%)

Branch coverage included in aggregate %.

46 of 54 new or added lines in 5 files covered. (85.19%)

384 of 402 relevant lines covered (95.52%)

94.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/src/common/utils/mapStore.ts
1
export class MapCacheStore<T> {
1✔
2
  private store: Map<string, Promise<T> | T>;
3

4
  constructor(public fullStorage: Map<string, Map<string, unknown>>, private readonly functionId: string) {}
7✔
5

6
  /**
7
   * Retrieves the value associated with the specified key.
8
   *
9
   * @param key - The key used to retrieve the value.
10
   * @returns The value corresponding to the key.
11
   */
12
  public get(key: string): T {
13
    this.fullStorage ??= new Map<string, Map<string, unknown>>();
7✔
14

15
    if (!this.fullStorage.has(this.functionId)) {
7✔
16
      this.fullStorage.set(this.functionId, new Map<string, unknown>());
2✔
17
    }
18

19
    this.store = this.fullStorage.get(this.functionId) as Map<string, Promise<T> | T>;
7✔
20

21
    return this.store.get(key) as T;
7✔
22
  }
23

24
  /**
25
   * Sets a value for the specified key.
26
   *
27
   * @param key - The key for the value.
28
   * @param value - The value to store.
29
   * @param ttl - Time to live in milliseconds (optional).
30
   * @returns The value that was set.
31
   */
32
  public set(key: string, value: T, ttl?: number): T {
33
    setTimeout(() => {
2✔
NEW
34
      this.store.delete(key);
×
NEW
35
      this.fullStorage.set(this.functionId, this.store);
×
36
    }, ttl);
37
    this.store.set(key, value);
2✔
38
    this.fullStorage.set(this.functionId, this.store);
2✔
39
    return value;
2✔
40
  }
41
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc