improve query cache with zstd level 9
Some checks failed
Go / build (push) Has been cancelled
Go / release (push) Has been cancelled

This commit is contained in:
2025-11-16 20:52:18 +00:00
parent dfe8b5f8b2
commit 511b8cae5f
7 changed files with 301 additions and 80 deletions

View File

@@ -13,6 +13,7 @@ import (
"lol.mleku.dev"
"lol.mleku.dev/chk"
"next.orly.dev/pkg/database/querycache"
"next.orly.dev/pkg/encoders/filter"
"next.orly.dev/pkg/utils/apputil"
"next.orly.dev/pkg/utils/units"
)
@@ -230,6 +231,24 @@ func (d *D) InvalidateQueryCache() {
}
}
// GetCachedJSON retrieves cached marshaled JSON for a filter
// Returns nil, false if not found
func (d *D) GetCachedJSON(f *filter.F) ([][]byte, bool) {
if d.queryCache == nil {
return nil, false
}
return d.queryCache.Get(f)
}
// CacheMarshaledJSON stores marshaled JSON event envelopes for a filter
func (d *D) CacheMarshaledJSON(f *filter.F, marshaledJSON [][]byte) {
if d.queryCache != nil && len(marshaledJSON) > 0 {
// Store the serialized JSON directly - this is already in envelope format
// We create a wrapper to store it with the right structure
d.queryCache.PutJSON(f, marshaledJSON)
}
}
// Close releases resources and closes the database.
func (d *D) Close() (err error) {
if d.seq != nil {