Documentation
¶
Index ¶
- func Escape(s string) string
- func RenderValue(v any) string
- type Cache
- type CacheEntry
- type CacheKeyGenerator
- type Config
- type DefaultCacheKeyGenerator
- type MemoryCache
- func (c *MemoryCache) Clear(ctx context.Context) error
- func (c *MemoryCache) Close() error
- func (c *MemoryCache) Delete(ctx context.Context, key string) error
- func (c *MemoryCache) Get(ctx context.Context, key string) (arrow.Record, error)
- func (c *MemoryCache) Put(ctx context.Context, key string, record arrow.Record) error
- type Stats
- type StatsCollector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderValue ¶
renderValue converts an arbitrary parameter value into a canonical string.
Types ¶
type Cache ¶
type Cache interface {
// Get retrieves a record batch from the cache
Get(ctx context.Context, key string) (arrow.Record, error)
// Put stores a record batch in the cache
Put(ctx context.Context, key string, record arrow.Record) error
// Delete removes a record batch from the cache
Delete(ctx context.Context, key string) error
// Clear removes all entries from the cache
Clear(ctx context.Context) error
// Close releases any resources held by the cache
Close() error
}
Cache defines the interface for caching Arrow record batches
type CacheEntry ¶
CacheEntry represents a single cache entry with metadata
type CacheKeyGenerator ¶
type CacheKeyGenerator interface {
GenerateKey(query string, params map[string]interface{}) string
}
CacheKeyGenerator defines the interface for generating cache keys
type Config ¶
type Config struct {
// MaxSize is the maximum size of the cache in bytes
MaxSize int64
// TTL is the time-to-live for cache entries
TTL time.Duration
// Allocator is the memory allocator to use
Allocator memory.Allocator
// EnableStats enables cache statistics collection
EnableStats bool
}
Config holds the configuration for the cache
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a default cache configuration
func (*Config) WithAllocator ¶
WithAllocator sets the memory allocator
func (*Config) WithMaxSize ¶
WithMaxSize sets the maximum size of the cache
type DefaultCacheKeyGenerator ¶
type DefaultCacheKeyGenerator struct{}
DefaultCacheKeyGenerator implements CacheKeyGenerator
func (*DefaultCacheKeyGenerator) GenerateKey ¶
func (g *DefaultCacheKeyGenerator) GenerateKey(query string, params map[string]interface{}) string
TODO:GenerateKey creates a deterministic cache‑key based on the SQL text (with whitespace normalised) and a stable, ordered serialisation of the parameter map.
The resulting key is a hex‑encoded SHA‑256 digest, keeping it short and collision‑resistant while hiding potentially sensitive values.
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache implements Cache interface using in-memory storage
func NewMemoryCache ¶
func NewMemoryCache(maxSize int64, alloc memory.Allocator) *MemoryCache
NewMemoryCache creates a new memory cache with the specified maximum size
func (*MemoryCache) Clear ¶
func (c *MemoryCache) Clear(ctx context.Context) error
Clear removes all entries from the cache
func (*MemoryCache) Close ¶
func (c *MemoryCache) Close() error
Close releases any resources held by the cache
func (*MemoryCache) Delete ¶
func (c *MemoryCache) Delete(ctx context.Context, key string) error
Delete removes a record batch from the cache
type StatsCollector ¶
type StatsCollector struct {
// contains filtered or unexported fields
}
StatsCollector collects and reports cache statistics
func NewStatsCollector ¶
func NewStatsCollector() *StatsCollector
NewStatsCollector creates a new statistics collector
func (*StatsCollector) GetStats ¶
func (c *StatsCollector) GetStats() Stats
GetStats returns the current cache statistics
func (*StatsCollector) HitRate ¶
func (c *StatsCollector) HitRate() float64
HitRate returns the cache hit rate
func (*StatsCollector) RecordEviction ¶
func (c *StatsCollector) RecordEviction()
RecordEviction records a cache eviction
func (*StatsCollector) RecordHit ¶
func (c *StatsCollector) RecordHit()
RecordHit records a cache hit
func (*StatsCollector) RecordMiss ¶
func (c *StatsCollector) RecordMiss()
RecordMiss records a cache miss
func (*StatsCollector) UpdateSize ¶
func (c *StatsCollector) UpdateSize(size int64)
UpdateSize updates the current cache size