Setup eslint and enforce rules
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
20
src/util/cache/InMemCache.ts
vendored
20
src/util/cache/InMemCache.ts
vendored
@@ -20,22 +20,28 @@ export class InMemCache extends Cache {
|
||||
*/
|
||||
protected items: Collection<InMemCacheItem> = new Collection<InMemCacheItem>()
|
||||
|
||||
public async fetch(key: string) {
|
||||
public async fetch(key: string): Promise<string | undefined> {
|
||||
const item = this.items.firstWhere('key', '=', key)
|
||||
if ( item ) return item.item
|
||||
if ( item ) {
|
||||
return item.item
|
||||
}
|
||||
}
|
||||
|
||||
public async put(key: string, item: string) {
|
||||
public async put(key: string, item: string): Promise<void> {
|
||||
const existing = this.items.firstWhere('key', '=', key)
|
||||
if ( existing ) existing.item = item
|
||||
else this.items.push({ key, item })
|
||||
if ( existing ) {
|
||||
existing.item = item
|
||||
} else {
|
||||
this.items.push({ key,
|
||||
item })
|
||||
}
|
||||
}
|
||||
|
||||
public async has(key: string) {
|
||||
public async has(key: string): Promise<boolean> {
|
||||
return this.items.where('key', '=', key).length > 0
|
||||
}
|
||||
|
||||
public async drop(key: string) {
|
||||
public async drop(key: string): Promise<void> {
|
||||
this.items = this.items.whereNot('key', '=', key)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user