Browse Source

make query cache normalize filters so same query different order filters are cache hits

main
mleku 2 months ago
parent
commit
beed174e83
No known key found for this signature in database
  1. 4
      pkg/database/querycache/event_cache.go
  2. 2
      pkg/version/version

4
pkg/database/querycache/event_cache.go vendored

@ -99,6 +99,8 @@ func NewEventCache(maxSize int64, maxAge time.Duration) *EventCache { @@ -99,6 +99,8 @@ func NewEventCache(maxSize int64, maxAge time.Duration) *EventCache {
// Get retrieves cached serialized events for a filter (decompresses on the fly)
func (c *EventCache) Get(f *filter.F) (serializedJSON [][]byte, found bool) {
// Normalize filter by sorting to ensure consistent cache keys
f.Sort()
filterKey := string(f.Serialize())
c.mu.RLock()
@ -173,6 +175,8 @@ func (c *EventCache) PutJSON(f *filter.F, marshaledJSON [][]byte) { @@ -173,6 +175,8 @@ func (c *EventCache) PutJSON(f *filter.F, marshaledJSON [][]byte) {
return
}
// Normalize filter by sorting to ensure consistent cache keys
f.Sort()
filterKey := string(f.Serialize())
// Concatenate all JSON events with newline delimiters for compression

2
pkg/version/version

@ -1 +1 @@ @@ -1 +1 @@
v0.29.0
v0.29.2
Loading…
Cancel
Save