refactor: remove Uuid and RoleName from @standardnotes/common in favour of @standardnotes/domain-core value objects (#2167)

This commit is contained in:
Karol Sójko
2023-01-19 16:17:59 +01:00
committed by GitHub
parent 2d63b7431a
commit 856a7e3500
108 changed files with 319 additions and 374 deletions

View File

@@ -1,15 +1,14 @@
import { removeFromArray } from '@standardnotes/utils'
import { Uuid } from '@standardnotes/common'
import { EncryptedBytes } from '../Types/EncryptedBytes'
export class FileMemoryCache {
private cache: Record<Uuid, EncryptedBytes> = {}
private orderedQueue: Uuid[] = []
private cache: Record<string, EncryptedBytes> = {}
private orderedQueue: string[] = []
constructor(public readonly maxSize: number) {}
add(uuid: Uuid, data: EncryptedBytes): boolean {
add(uuid: string, data: EncryptedBytes): boolean {
if (data.encryptedBytes.length > this.maxSize) {
return false
}
@@ -31,11 +30,11 @@ export class FileMemoryCache {
.reduce((total, fileLength) => total + fileLength, 0)
}
get(uuid: Uuid): EncryptedBytes | undefined {
get(uuid: string): EncryptedBytes | undefined {
return this.cache[uuid]
}
remove(uuid: Uuid): void {
remove(uuid: string): void {
delete this.cache[uuid]
removeFromArray(this.orderedQueue, uuid)