-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): use quick-lru for documents edit state
- Loading branch information
1 parent
9665c98
commit 1b52fad
Showing
6 changed files
with
197 additions
and
290 deletions.
There are no files selected for viewing
This file contains 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
76 changes: 0 additions & 76 deletions
76
packages/sanity/src/core/store/_legacy/document/document-pair/utils/localStoragePOC.ts
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
21 changes: 21 additions & 0 deletions
21
packages/sanity/src/core/store/_legacy/document/documentsStorage.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {type SanityDocument} from '@sanity/types' | ||
import QuickLRU from 'quick-lru' | ||
|
||
export interface DocumentsStorage { | ||
save: (id: string, doc: SanityDocument) => void | ||
get: (id: string) => SanityDocument | null | ||
} | ||
|
||
export function createDocumentsStorage(): DocumentsStorage { | ||
const documentsCache = new QuickLRU<string, SanityDocument | null>({ | ||
maxSize: 50, | ||
}) | ||
return { | ||
save(id, doc) { | ||
documentsCache.set(id, doc) | ||
}, | ||
get(id) { | ||
return documentsCache.get(id) || null | ||
}, | ||
} | ||
} |
Oops, something went wrong.