improve query cache with zstd level 9
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user