mirror of
https://github.com/aljazceru/njump.git
synced 2026-02-19 04:54:27 +01:00
Avoid caching empty reply/note lists
This commit is contained in:
4
nostr.go
4
nostr.go
@@ -172,7 +172,9 @@ func relaysForPubkey(ctx context.Context, pubkey string, extraRelays ...string)
|
||||
}
|
||||
}
|
||||
cancel()
|
||||
cache.SetJSONWithTTL("io:"+pubkey, pubkeyRelays, time.Hour*24*7)
|
||||
if len(pubkeyRelays) > 0 {
|
||||
cache.SetJSONWithTTL("io:"+pubkey, pubkeyRelays, time.Hour*24*7)
|
||||
}
|
||||
}
|
||||
return pubkeyRelays
|
||||
}
|
||||
|
||||
@@ -107,7 +107,9 @@ func render(w http.ResponseWriter, r *http.Request) {
|
||||
ctx, cancel := context.WithTimeout(r.Context(), time.Second*4)
|
||||
lastNotes = getLastNotes(ctx, code, events_num)
|
||||
cancel()
|
||||
cache.SetJSONWithTTL(key, lastNotes, time.Hour*24)
|
||||
if len(lastNotes) > 0 {
|
||||
cache.SetJSONWithTTL(key, lastNotes, time.Hour*24)
|
||||
}
|
||||
}
|
||||
|
||||
renderableLastNotes = make([]*Event, len(lastNotes))
|
||||
|
||||
Reference in New Issue
Block a user