make query cache normalize filters so same query different order filters are cache hits
Some checks failed
Go / build (push) Has been cancelled
Go / release (push) Has been cancelled

This commit is contained in:
2025-11-17 00:04:21 +00:00
parent 511b8cae5f
commit beed174e83
3 changed files with 8 additions and 4 deletions

View File

@@ -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) {
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