Skip to content

Commit

Permalink
v4.12.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaschan committed Apr 25, 2024
1 parent e2aabc0 commit 2485f09
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bell-countdown",
"version": "4.12.1",
"version": "4.12.2",
"description": "Countdown to the next time the bell rings at school.",
"main": "index.js",
"scripts": {
Expand Down
14 changes: 9 additions & 5 deletions server/cache2.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ class Cache {
async get (key, f) {
const cached = this.cache[key]
if (cached && Date.now() > cached.expires) {
const value = await f(key)
if (value) {
this.set(key, value, this.defaultTtlSeconds)
return value
try {
const value = await f(key)
if (value) {
this.set(key, value, this.defaultTtlSeconds)
return value
}
return cached.value
} catch (e) {
return cached.value
}
return cached.value
}
if (cached) {
return cached.value
Expand Down

0 comments on commit 2485f09

Please sign in to comment.