cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Now = time.Now

Functions

func ReadLine

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

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{}) 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

	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 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 Index

type Index struct {
	By      string
	SQL     string
	Ordered bool //SQL uses order by indexby column
	Args    []interface{}
	In      []interface{}
	Offset  int
	Limit   int
	OnSkip  func(values []interface{}) error
	// contains filtered or unexported fields
}

Index abstraction to represent data optimisation with caching and custom pagination

func (*Index) Init

func (m *Index) Init()

func (*Index) MarshalArgs

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

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
	TimeToLive int
	Fields     []*Field

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

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 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

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

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
}

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