Versions in this module Expand all Collapse all v0 v0.1.0 Jul 22, 2026 Changes in this version + var ErrClientClosed = errors.New("predictivecache client is closed") + func WithBindValue(ctx context.Context, key string, value any) context.Context + func WithRoute(ctx context.Context, route string) context.Context + func WithSessionID(ctx context.Context, sessionID string) context.Context + func WithTenant(ctx context.Context, tenant string) context.Context + type BindingExplain struct + Args []BoundArgument + Confidence float64 + Executable bool + RejectionReason string + SQL string + TemplateID TemplateID + type BindingSource string + const BindingSourceContextValue + const BindingSourcePreviousArg + const BindingSourceRecentSemantic + type BoundArgument struct + Confidence float64 + Name string + Position int + Source BindingSource + SourceArgPosition int + Type string + Value string + type Client struct + func Open(driverName string, dsn string, opts ...Option) (*Client, error) + func Wrap(db *sql.DB, dialect Dialect, opts ...Option) (*Client, error) + func (c *Client) Close() error + func (c *Client) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) + func (c *Client) Explain(ctx context.Context, query string, args ...any) (*ExplainResult, error) + func (c *Client) InvalidateAll() error + func (c *Client) InvalidateTables(tables ...string) error + func (c *Client) QueryContext(ctx context.Context, query string, args ...any) (*Rows, error) + func (c *Client) QueryRowContext(ctx context.Context, query string, args ...any) *Row + func (c *Client) Stats() StatsSnapshot + type Dialect string + const DialectPostgres + type ExplainResult struct + BindingCandidates []BindingExplain + Cacheable bool + ContextHistory []TemplateID + PredictionCandidates []Prediction + PredictionSource string + StructuralNeighbors []StructuralNeighbor + Template Template + type FeatureMap map[string]float64 + type Operation uint8 + const OpSelect + const OpUtility + const OpWrite + type Option func(*options) + func WithBindingConfidenceThreshold(threshold float64) Option + func WithBindingMinTrials(trials int) Option + func WithCacheTTL(ttl time.Duration) Option + func WithEventChannelSize(size int) Option + func WithLogDir(dir string) Option + func WithMaxBindingRules(limit int) Option + func WithMaxCacheBytes(bytes int64) Option + func WithMaxCacheEntryBytes(bytes int64) Option + func WithMaxCacheRows(rows int) Option + func WithMaxContextOrder(order int) Option + func WithMaxPredictionCandidates(limit int) Option + func WithMaxSessions(limit int) Option + func WithMaxStructuralFeaturesPerTemplate(limit int) Option + func WithMaxStructuralNeighbors(limit int) Option + func WithMaxStructuralTemplates(limit int) Option + func WithMinEventsBeforePrefetch(events int) Option + func WithPersistRawSQL(enabled bool) Option + func WithPersistenceBatchSize(size int) Option + func WithPersistenceInterval(interval time.Duration) Option + func WithPredictionAlpha(alpha float64) Option + func WithPredictionConfidenceThreshold(threshold float64) Option + func WithPrefetchConcurrency(concurrency int) Option + func WithPrefetchEnabled(enabled bool) Option + func WithPrefetchMaxQPS(qps int) Option + func WithPrefetchQueueSize(size int) Option + func WithPrefetchTimeout(timeout time.Duration) Option + func WithStructuralColdStartPenalty(penalty float64) Option + func WithStructuralFallbackEnabled(enabled bool) Option + func WithStructuralMinSimilarity(similarity float64) Option + func WithStructuralPrefetchConfidence(threshold float64) Option + type Prediction struct + BorrowedFrom TemplateID + Confidence float64 + ContextOrder int + Probability float64 + Source string + StructuralOverlap []string + StructuralSimilarity float64 + TemplateID TemplateID + type Row struct + func (r *Row) Scan(dest ...any) error + type Rows struct + func (r *Rows) Close() error + func (r *Rows) ColumnTypes() ([]*sql.ColumnType, error) + func (r *Rows) Columns() ([]string, error) + func (r *Rows) Err() error + func (r *Rows) FromCache() bool + func (r *Rows) Next() bool + func (r *Rows) Scan(dest ...any) error + type StatsSnapshot struct + BindingAccepted uint64 + BindingAttempts uint64 + BindingRejectedLowConfidence uint64 + BindingRejectedUnbound uint64 + BindingRulesTotal int64 + CacheBytes int64 + CacheEntries int64 + CacheHits uint64 + CacheInvalidations uint64 + CacheMisses uint64 + CacheRejected uint64 + CacheStaleMisses uint64 + EventsDropped uint64 + FullCacheInvalidations uint64 + ParseErrors uint64 + PersistenceErrors uint64 + PersistenceFlushes uint64 + PersistenceLoads uint64 + PersistenceRecoveries uint64 + PredictionAccuracyAt1 float64 + PredictionAccuracyAt3 float64 + PredictionsEvaluated uint64 + PredictionsTotal uint64 + PrefetchAccepted uint64 + PrefetchAttempts uint64 + PrefetchCandidates uint64 + PrefetchCompleted uint64 + PrefetchErrors uint64 + PrefetchHits uint64 + PrefetchRejectedDuplicate uint64 + PrefetchRejectedLowConfidence uint64 + PrefetchRejectedQueueFull uint64 + PrefetchRejectedStale uint64 + PrefetchRejectedUnbound uint64 + PrefetchTimeouts uint64 + PrefetchWasted uint64 + QueriesTotal uint64 + SelectsTotal uint64 + SessionsTotal int64 + StructuralFallbackAccepted uint64 + StructuralFallbackAccuracyAt1 float64 + StructuralFallbackCandidates uint64 + StructuralFallbackEvaluated uint64 + StructuralTemplatesTotal int64 + TableVersionInvalidations uint64 + TemplatesTotal int64 + TransitionContextsTotal int64 + WritesTotal uint64 + type StructuralNeighbor struct + Overlap []string + Similarity float64 + TemplateID TemplateID + type Template struct + ArgNames []string + Cacheable bool + CanonicalSQL string + DBLatency time.Duration + EstimatedCost time.Duration + ExecutableSQL string + ExecutableSQLReady bool + ExpectedRows int + Fingerprint string + FingerprintHash uint64 + ID TemplateID + Name string + Operation Operation + ReadTables []string + ResultBytes int + StructuralFeatures FeatureMap + StructuralFeaturesKnown bool + TableDependenciesKnown bool + WriteTables []string + type TemplateID uint64