cache

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 19 Imported by: 3

Documentation

Index

Constants

View Source
const (
	TypeReadMulti  = "warmup"
	TypeReadSingle = "lazy"
	TypeWrite      = "write"
	TypeNone       = "none"

	ErrorNone                      = ""
	ErrorTypeTimeout               = "aerospike timeout error"
	ErrorTypeServerUnavailable     = "aerospike server unavailable node"
	ErrorTypeServerGeneric         = "aerospike error occured"
	ErrorTypeCurrentlyNotAvailable = "aerospike currently not available"
)

Variables

View Source
var Now = time.Now

Functions

func EmitIndexProgress added in v0.24.0

func EmitIndexProgress(ctx context.Context, event *IndexProgressEvent)

func ReadLine

func ReadLine(reader LineReader) ([]byte, error)

func WithIndexProgress added in v0.24.0

func WithIndexProgress(ctx context.Context, progress *IndexProgress) context.Context

func WithIndexProgressCallback added in v0.24.0

func WithIndexProgressCallback(ctx context.Context, callback IndexProgressFn) context.Context

Types

type AllowSmart

type AllowSmart bool

type Cache

type Cache interface {
	AsSource(ctx context.Context, entry *Entry) (Source, error)
	AddValues(ctx context.Context, entry *Entry, values []interface{}) error
	Get(ctx context.Context, sql string, args []interface{}, options ...interface{}) (*Entry, error)
	AssignRows(entry *Entry, rows *sql.Rows) error
	UpdateType(ctx context.Context, entry *Entry, args []interface{}) (bool, error)
	Close(ctx context.Context, entry *Entry) error
	Delete(todo context.Context, entry *Entry) error
	Rollback(ctx context.Context, entry *Entry) error
	IndexBy(ctx context.Context, db *sql.DB, column, SQL string, args []interface{}, options ...interface{}) (int, error)
}

type ColumnsHolder

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

func NewColumnsHolder

func NewColumnsHolder(entry *Entry) *ColumnsHolder

func (*ColumnsHolder) ConvertColumns

func (s *ColumnsHolder) ConvertColumns() ([]io.Column, error)

type Decoder

type Decoder struct {
	Data []byte
	// contains filtered or unexported fields
}

func NewDecoder

func NewDecoder(scanTypes []reflect.Type, data []byte) *Decoder

func (*Decoder) UnmarshalJSONArray

func (d *Decoder) UnmarshalJSONArray(decoder *gojay.Decoder) error

type DecoderFn

type DecoderFn func(decoder *gojay.Decoder) (interface{}, error)

type Entry

type Entry struct {
	Meta        Meta
	Data        []byte // Entry is used as Iterator, Data is last streamed line.
	Id          string
	WriteCloser *WriteCloser
	ReadCloser  *ReadCloser
	Refresh     bool

	RowAdded bool
	// contains filtered or unexported fields
}

func (*Entry) AssignRows

func (e *Entry) AssignRows(rows *sql.Rows) error

func (*Entry) Close

func (e *Entry) Close() error

func (*Entry) Has

func (e *Entry) Has() bool

func (*Entry) Next

func (e *Entry) Next() bool

func (*Entry) SetReader

func (e *Entry) SetReader(reader Reader, closer goIo.Closer)

func (*Entry) SetWriter

func (e *Entry) SetWriter(writer Writer, closer goIo.Closer)

func (*Entry) Write

func (e *Entry) Write(data []byte) error

type ErrorType added in v0.2.0

type ErrorType string

type Field

type Field struct {
	ColumnName      string
	ColumnLength    int64
	ColumnPrecision int64
	ColumnScale     int64
	ColumnScanType  string

	ColumnNullable     bool
	ColumnDatabaseName string
	ColumnTag          *io.Tag
	// contains filtered or unexported fields
}

func ColumnsToFields

func ColumnsToFields(ioColumns []io.Column) ([]*Field, error)

func (*Field) DatabaseTypeName

func (f *Field) DatabaseTypeName() string

func (*Field) DecimalSize

func (f *Field) DecimalSize() (precision, scale int64, ok bool)

func (*Field) Init

func (f *Field) Init() error

func (*Field) Length

func (f *Field) Length() (length int64, ok bool)

func (*Field) Name

func (f *Field) Name() string

func (*Field) Nullable

func (f *Field) Nullable() (nullable, ok bool)

func (*Field) ScanType

func (f *Field) ScanType() reflect.Type

func (*Field) Tag

func (f *Field) Tag() *io.Tag

type IndexByResult added in v0.24.0

type IndexByResult struct {
	GroupsWritten int
	WarmupKey     string
	MarkerKey     string
}

type IndexProgress added in v0.24.0

type IndexProgress struct {
	View    string
	Dataset string
	Case    string
}

func IndexProgressFromContext added in v0.24.0

func IndexProgressFromContext(ctx context.Context) (*IndexProgress, bool)

type IndexProgressEvent added in v0.24.0

type IndexProgressEvent struct {
	View    string
	Dataset string
	Case    string
	Column  string
	Rows    int
	Elapsed time.Duration
	Done    bool
}

type IndexProgressFn added in v0.24.0

type IndexProgressFn func(event *IndexProgressEvent)

func IndexProgressCallbackFromContext added in v0.24.0

func IndexProgressCallbackFromContext(ctx context.Context) (IndexProgressFn, bool)

type Indexed

type Indexed struct {
	ColumnValue interface{}
	Data        *bytes.Buffer
	Column      string
}

func NewIndexed

func NewIndexed(columnValue interface{}) *Indexed

func (*Indexed) StringifyData

func (i *Indexed) StringifyData(data []interface{}) error

type LineReader

type LineReader interface {
	ReadLine() (line []byte, prefix bool, err error)
}

type LineWriter

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

func (*LineWriter) Flush

func (l *LineWriter) Flush() error

func (*LineWriter) Write

func (l *LineWriter) Write(p []byte) (n int, err error)

type Meta

type Meta struct {
	SQL          string
	Args         []byte
	Type         []string
	Signature    string
	ExpiryTimeMs int
	Fields       []*Field
	StoredFields []ProjectionField
	// ProjectedIndexes maps requested result columns to stored cached row ordinals.
	// It is runtime-only metadata used when reading a warmup superset as a subset.
	ProjectedIndexes []int `json:"-" yaml:"-"`

	URL string `json:"-" yaml:"-"`
}

func (*Meta) EffectiveFields added in v0.24.0

func (m *Meta) EffectiveFields() []*Field

func (*Meta) EffectiveType added in v0.24.0

func (m *Meta) EffectiveType() []string

func (*Meta) Projected added in v0.24.0

func (m *Meta) Projected() bool

type ParmetrizedQuery added in v0.2.0

type ParmetrizedQuery struct {
	By           string
	SQL          string
	IdentitySQL  string
	Ordered      bool //SQL uses order by indexby column
	Args         []interface{}
	IdentityArgs []interface{}
	StoredFields []ProjectionField
	// RequestedFields describes the caller's logical projection for warmup subset reads.
	RequestedFields []ProjectionField
	In              []interface{}
	Offset          int
	Limit           int
	OnSkip          func(values []interface{}) error
	// contains filtered or unexported fields
}

ParmetrizedQuery abstraction to represent data optimisation with caching and custom pagination

func (*ParmetrizedQuery) Init added in v0.2.0

func (m *ParmetrizedQuery) Init()

func (*ParmetrizedQuery) MarshalArgs added in v0.2.0

func (m *ParmetrizedQuery) MarshalArgs() ([]byte, error)

func (*ParmetrizedQuery) MarshalIdentityArgs added in v0.24.0

func (m *ParmetrizedQuery) MarshalIdentityArgs() ([]byte, error)

func (*ParmetrizedQuery) WarmupIdentity added in v0.24.0

func (m *ParmetrizedQuery) WarmupIdentity() (string, []interface{}, []byte, error)

func (*ParmetrizedQuery) WarmupIdentityResolved added in v0.24.0

func (m *ParmetrizedQuery) WarmupIdentityResolved() (string, []interface{}, []byte, WarmupIdentityMeta, error)

type ProjectionField added in v0.24.0

type ProjectionField struct {
	Name         string   `json:",omitempty"`
	FieldName    string   `json:",omitempty"`
	ColumnName   string   `json:",omitempty"`
	Source       string   `json:",omitempty"`
	DimensionKey string   `json:",omitempty"`
	MeasureKey   string   `json:",omitempty"`
	Lookup       []string `json:",omitempty"`
}

type ReadCloser

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

func NewReadCloser

func NewReadCloser(reader Reader, closer io.Closer) *ReadCloser

func (*ReadCloser) Close

func (w *ReadCloser) Close() error

func (*ReadCloser) Read

func (w *ReadCloser) Read(p []byte) (n int, err error)

func (*ReadCloser) ReadLine

func (w *ReadCloser) ReadLine() (line []byte, prefix bool, err error)

type Reader

type Reader interface {
	io.Reader
	LineReader
}

type Recorder

type Recorder interface {
	AddValues(values []interface{})
	ScanValues(values []interface{})
}

type Refresh added in v0.9.1

type Refresh bool

Refresh forecase cache refresh

type ScanTypeHolder

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

func (*ScanTypeHolder) InitType

func (t *ScanTypeHolder) InitType(values []interface{})

func (*ScanTypeHolder) Match

func (t *ScanTypeHolder) Match(entry *Entry) bool

func (*ScanTypeHolder) Mismatch added in v0.24.0

func (t *ScanTypeHolder) Mismatch(entry *Entry) *TypeMismatch

type Scanner

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

func NewScanner

func NewScanner(typeHolder *ScanTypeHolder, recorder Recorder) *Scanner

func (*Scanner) New

func (c *Scanner) New(e *Entry) ScannerFn

type ScannerFn

type ScannerFn func(args ...interface{}) error

func NewProjectedScanner added in v0.24.0

func NewProjectedScanner(entry *Entry, indexes []int, typeHolder *ScanTypeHolder, recorder Recorder) ScannerFn

type Source

type Source interface {
	ConvertColumns() ([]io.Column, error)
	Scanner(context.Context) ScannerFn
	XTypes() []*xunsafe.Type
	CheckType(ctx context.Context, values []interface{}) (bool, error)
	Close(ctx context.Context) error
	Next() bool
	Rollback(ctx context.Context) error
	Err() error
}

type Stats added in v0.2.0

type Stats struct {
	Type           Type
	RecordsCounter int
	Key            string
	WarmupKey      string
	MarkerKey      string
	Dataset        string
	Namespace      string
	FoundWarmup    bool             `json:",omitempty"`
	FoundLazy      bool             `json:",omitempty"`
	ErrorType      string           `json:",omitempty"`
	ErrorCode      types.ResultCode `json:",omitempty"`
	ExpiryTime     *time.Time
}

func (*Stats) FoundAny added in v0.2.0

func (s *Stats) FoundAny() bool

func (*Stats) Init added in v0.2.0

func (s *Stats) Init()

type Type added in v0.2.0

type Type string

type TypeMismatch added in v0.24.0

type TypeMismatch struct {
	Index                int
	DestinationType      string
	NormalizedDestType   string
	CachedType           string
	NormalizedCachedType string
	Reason               string
}

type WarmupIdentityMeta added in v0.24.0

type WarmupIdentityMeta struct {
	Source string
	Detail string
}

type WarmupIndexer added in v0.24.0

type WarmupIndexer interface {
	IndexByWithResult(ctx context.Context, db *sql.DB, column, SQL string, args []interface{}, options ...interface{}) (*IndexByResult, error)
}

type WriteCloser

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

func NewWriteCloser

func NewWriteCloser(writer Writer, closer io.Closer) *WriteCloser

func (*WriteCloser) Close

func (w *WriteCloser) Close() error

func (*WriteCloser) Flush

func (w *WriteCloser) Flush() error

func (*WriteCloser) Write

func (w *WriteCloser) Write(p []byte) (n int, err error)

type Writer

type Writer interface {
	io.Writer
	Flush() error
}

func NewLineWriter

func NewLineWriter(writer Writer) Writer

type XTypesHolder

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

func NewXTypeHolder

func NewXTypeHolder(entry *Entry) *XTypesHolder

func (*XTypesHolder) XTypes

func (s *XTypesHolder) XTypes() []*xunsafe.Type

Directories

Path Synopsis
ast

Jump to

Keyboard shortcuts

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