cockroach: Index | Files

package querycache

import ""


Package Files


type C Uses

type C struct {
    // contains filtered or unexported fields

C is a query cache, keyed on SQL statement strings (which can contain placeholders).

A cache can be used by multiple threads in parallel; however each different context must use its own Session.

func New Uses

func New(memorySize int64) *C

New creates a query cache of the given size.

func (*C) Add Uses

func (c *C) Add(session *Session, d *CachedData)

Add adds an entry to the cache (possibly evicting some other entry). If the cache already has a corresponding entry for d.SQL, it is updated. Note: d.PrepareMetadata cannot be modified once this method is called.

func (*C) Clear Uses

func (c *C) Clear()

Clear removes all the entries from the cache.

func (*C) Find Uses

func (c *C) Find(session *Session, sql string) (_ CachedData, ok bool)

Find returns the entry for the given query, if it is in the cache.

If any cached data needs to be updated, it must be done via Add. In particular, PrepareMetadata in the returned CachedData must not be modified.

func (*C) Purge Uses

func (c *C) Purge(sql string)

Purge removes the entry for the given query, if it exists.

type CachedData Uses

type CachedData struct {
    SQL  string
    Memo *memo.Memo
    // PrepareMetadata is set for prepare queries. In this case the memo contains
    // unassigned placeholders. For non-prepared queries, it is nil.
    PrepareMetadata *sqlbase.PrepareMetadata
    // IsCorrelated memoizes whether the query contained correlated
    // subqueries during planning (prior to de-correlation).
    IsCorrelated bool

CachedData is the data associated with a cache entry.

type Session Uses

type Session struct {
    // contains filtered or unexported fields

Session stores internal information related to a single session. A session cannot be used by multiple threads in parallel.

func (*Session) Init Uses

func (s *Session) Init()

Init initializes or resets a Session.

Package querycache imports 5 packages (graph) and is imported by 7 packages. Updated 2020-08-09. Refresh now. Tools for package owners.