Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mairatma committed Nov 8, 2023
1 parent 7f62e70 commit 8e58d42
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/caches/LRUDiskCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export type LRUData = Record<string, unknown> & { timeOfDeath: number }

export class LRUDiskCache<V> implements CacheLayer<string, V>{

private lock: ReadWriteLock
protected disposed: number
protected hits = 0
protected total = 0
private lock: ReadWriteLock
private lruStorage: LRU<string, LRUData>
private keyToBeDeleted: string

Expand All @@ -40,19 +40,6 @@ export class LRUDiskCache<V> implements CacheLayer<string, V>{

}

/**
* Builds the data object that will be stored at the LRU memory storage.
* Subclasses that need to store more than just the time of death should
* override this.
*/
protected buildLRUData(timeOfDeath: number, localCacheOptions?: LocalCacheOptions): LRUData {
return { timeOfDeath }
}

protected getLRU() {
return this.lruStorage
}

public has (key: string): boolean {
return this.lruStorage.has(key)
}
Expand Down Expand Up @@ -112,7 +99,7 @@ export class LRUDiskCache<V> implements CacheLayer<string, V>{
}

public async set (key: string, value: V, maxAge?: number, localCacheOptions?: LocalCacheOptions): Promise<boolean> {
let timeOfDeath = maxAge ? maxAge + Date.now() : NaN
const timeOfDeath = maxAge ? maxAge + Date.now() : NaN
const lruData = this.buildLRUData(timeOfDeath, localCacheOptions)
this.lruStorage.set(key, lruData, maxAge ? maxAge : undefined)

Expand All @@ -137,6 +124,19 @@ export class LRUDiskCache<V> implements CacheLayer<string, V>{
return !failure
}

/**
* Builds the data object that will be stored at the LRU memory storage.
* Subclasses that need to store more than just the time of death should
* override this.
*/
protected buildLRUData(timeOfDeath: number, localCacheOptions?: LocalCacheOptions): LRUData {
return { timeOfDeath }
}

protected getLRU() {
return this.lruStorage
}

private getPathKey = (key: string): string => {
return join(this.cachePath, key)
}
Expand Down

0 comments on commit 8e58d42

Please sign in to comment.