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:
10
src/support/cache/MemoryCache.ts
vendored
10
src/support/cache/MemoryCache.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import {Cache, Collection, Awaitable} from "../../util"
|
||||
import {Cache, Collection, Awaitable} from '../../util'
|
||||
|
||||
/**
|
||||
* An in-memory implementation of the Cache.
|
||||
@@ -23,17 +23,19 @@ export class MemoryCache extends Cache {
|
||||
existing.value = value
|
||||
existing.expires = expires
|
||||
} else {
|
||||
MemoryCache.cacheItems.push({ key, value, expires })
|
||||
MemoryCache.cacheItems.push({ key,
|
||||
value,
|
||||
expires })
|
||||
}
|
||||
}
|
||||
|
||||
public has(key: string): Awaitable<boolean> {
|
||||
const now = new Date()
|
||||
return !!MemoryCache.cacheItems
|
||||
return Boolean(MemoryCache.cacheItems
|
||||
.where('key', '=', key)
|
||||
.firstWhere(item => {
|
||||
return !item.expires || now < item.expires
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
public drop(key: string): Awaitable<void> {
|
||||
|
||||
Reference in New Issue
Block a user