]> git.codecow.com Git - nano-pow.git/commitdiff
Export cache as object only.
authorChris Duncan <chris@codecow.com>
Mon, 25 May 2026 05:33:15 +0000 (22:33 -0700)
committerChris Duncan <chris@codecow.com>
Mon, 25 May 2026 05:33:15 +0000 (22:33 -0700)
src/utils/cache.ts

index 6e86a3fe3335ee44cf884695e95b24edd0fe9c44..f40ddb9f216c9bec7d5ef623be11788ce4450d50 100644 (file)
@@ -28,11 +28,11 @@ function setItem (key: string, item: string): void {
        storage[key] = item
 }
 
-export function clear (): void {
+function clear (): void {
        removeItem(STORAGE_KEY)
 }
 
-export function get (hash: bigint, difficulty: bigint): WorkGenerateResponse | null {
+function get (hash: bigint, difficulty: bigint): WorkGenerateResponse | null {
        const item = getItem(STORAGE_KEY)
        if (item == null) return null
        const cache: WorkGenerateResponse[] = JSON.parse(item)
@@ -40,7 +40,7 @@ export function get (hash: bigint, difficulty: bigint): WorkGenerateResponse | n
        return match ?? null
 }
 
-export function remove (hash: bigint): void {
+function remove (hash: bigint): void {
        const item = getItem(STORAGE_KEY)
        if (item == null) return
        const cache = JSON.parse(item) as WorkGenerateResponse[]
@@ -52,7 +52,7 @@ export function remove (hash: bigint): void {
        setItem(STORAGE_KEY, JSON.stringify(cache))
 }
 
-export function set (result: WorkGenerateResponse): WorkGenerateResponse {
+function set (result: WorkGenerateResponse): WorkGenerateResponse {
        const item = getItem(STORAGE_KEY) ?? '[]'
        const cache: WorkGenerateResponse[] = JSON.parse(item)
        if (cache.push(result) > 1000) cache.shift()