Skip to content

Commit

Permalink
feat(core): use LRU cache for DevKvAdapter (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
deini committed Apr 17, 2024
1 parent d5d823d commit fe34b3e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/empty-carrots-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": patch
---

use LRU cache for DevKvAdapter
6 changes: 5 additions & 1 deletion apps/core/lib/kv/adapters/dev.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable @typescript-eslint/require-await */
import { LRUCache } from 'lru-cache';

import { KvAdapter } from '../types';

interface CacheEntry {
Expand All @@ -7,7 +9,9 @@ interface CacheEntry {
}

export class DevKvAdapter implements KvAdapter {
private kv = new Map<string, CacheEntry>();
private kv = new LRUCache<string, CacheEntry>({
max: 500,
});

constructor() {
// eslint-disable-next-line no-console
Expand Down
1 change: 1 addition & 0 deletions apps/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"gql.tada": "^1.4.3",
"graphql": "^16.8.1",
"lodash.debounce": "^4.0.8",
"lru-cache": "^10.2.0",
"lucide-react": "^0.365.0",
"next": "14.1.4",
"next-auth": "5.0.0-beta.16",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fe34b3e

Please sign in to comment.