Skip to content

Commit

Permalink
v4.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaschan committed Apr 25, 2024
1 parent 304f36c commit e2aabc0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bell-countdown",
"version": "4.12.0",
"version": "4.12.1",
"description": "Countdown to the next time the bell rings at school.",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -94,4 +94,4 @@
"webpack-dev-middleware": "^5.3.3",
"webpack-merge": "^5.8.0"
}
}
}
11 changes: 8 additions & 3 deletions server/cache2.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ class Cache {

async get (key, f) {
const cached = this.cache[key]
if (cached) {
if (Date.now() > cached.expires) {
this.invalidate(key)
if (cached && Date.now() > cached.expires) {
const value = await f(key)
if (value) {
this.set(key, value, this.defaultTtlSeconds)
return value
}
return cached.value
}
if (cached) {
return cached.value
}
if (f == null) {
return null
}
Expand Down

0 comments on commit e2aabc0

Please sign in to comment.