preparedcache

package
v0.0.0-...-230ac96 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package preparedcache is a per-connection LRU prepared-statement cache used by the PostgreSQL proxy. Plan 05a uses it for the wire-protocol Extended Query cache; Plan 05b adds a second instance per connection for SQL-level PREPARE/EXECUTE.

The default capacity is 4096 entries per spec §7.4.

Index

Constants

View Source
const DefaultCapacity = 4096

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache is a fixed-capacity LRU keyed by prepared-statement name. Empty name is a legal key per §7.4 (unnamed prepared statement).

func New

func New(capacity int) *Cache

New returns a Cache with the given capacity. capacity <= 0 falls back to DefaultCapacity.

func (*Cache) Clear

func (c *Cache) Clear()

Clear empties the cache.

func (*Cache) Delete

func (c *Cache) Delete(name string)

Delete removes name if present. No-op on miss.

func (*Cache) Get

func (c *Cache) Get(name string) (Entry, bool)

Get returns the cached entry and promotes it to MRU. Second return is false on miss.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the current entry count.

func (*Cache) Put

func (c *Cache) Put(name string, e Entry)

Put inserts or updates name -> e. Existing entries are promoted to MRU. At capacity, the LRU entry is evicted.

type Entry

type Entry struct {
	Classification           effects.ClassifiedStatement
	RedactionTier            policy.RedactionTier
	CatalogRefreshSearchPath bool
	CatalogRefreshSnapshot   bool
	Redirect                 *RedirectMetadata
}

Entry is the cached value: the classified statement plus the redaction tier captured at Parse time so a later Execute renders consistently even if policy is hot-swapped between Parse and Execute.

type RedirectMetadata

type RedirectMetadata struct {
	OriginalClassification   effects.ClassifiedStatement
	OriginalSQL              string
	OriginalStatementDigest  string
	RewrittenStatementDigest string
	Rule                     string
	SourceRelation           string
	TargetRelation           string
	PolicyIdentity           string
}

RedirectMetadata captures parse-time redirect state for wire-protocol prepared statements. Classification on Entry is the rewritten statement; OriginalClassification keeps the client statement for audit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL