Documentation ¶
Index ¶
- Variables
- func InitSchema(conn sqliteConn, pageSize int, triggers bool) (err error)
- func TestingTempCachePath(c testing.TB) string
- type Blob
- func (b Blob) Delete() error
- func (p Blob) GetTag(name string, result func(stmt SqliteStmt)) error
- func (b Blob) LastUsed() (lastUsed time.Time, err error)
- func (p Blob) ReadAt(b []byte, off int64) (n int, err error)
- func (p Blob) SetTag(name string, value interface{}) (err error)
- func (p Blob) Size() (l int64, err error)
- func (p Blob) WriteAt(b []byte, off int64) (n int, err error)
- type Cache
- func (c *Cache) BlobWithLength(name string, length int64) Blob
- func (c *Cache) Close() (err error)
- func (c *Cache) Create(name string, opts CreateOpts) (ret CachePinnedBlob, err error)
- func (cl *Cache) GetCapacity() (ret int64, ok bool)
- func (c *Cache) NewBlobRef(name string) Blob
- func (c *Cache) OpenPinnedReadOnly(name string) (ret CachePinnedBlob, err error)
- func (c *Cache) OpenWithLength(name string, length int64) Blob
- func (c *Cache) Put(name string, b []byte) (err error)
- func (c *Cache) ReadAll(key string, b []byte) (ret []byte, err error)
- func (c *Cache) ReadFull(key string, b []byte) (n int, err error)
- func (c *Cache) SetTag(key, name string, value interface{}) (err error)
- func (c *Cache) Tx(f func(tx *Tx) error) (err error)
- func (c *Cache) TxImmediate(f func(tx *Tx) error) (err error)
- type CachePinnedBlob
- type Cacher
- type CreateOpts
- type ErrUnexpectedJournalMode
- type InitConnOpts
- type InitDbOpts
- type NewCacheOpts
- type NewConnOpts
- type PinnedBlob
- func (pb *PinnedBlob) Close() error
- func (pb *PinnedBlob) LastUsed() (lastUsed time.Time, err error)
- func (pb *PinnedBlob) Length() int64
- func (pb *PinnedBlob) LengthErr() (_ int64, err error)
- func (pb *PinnedBlob) ReadAt(b []byte, valueOff int64) (n int, err error)
- func (pb *PinnedBlob) WriteAt(b []byte, off int64) (n int, err error)
- type SqliteStmt
- type Tx
- func (tx *Tx) Create(name string, opts CreateOpts) (pb *PinnedBlob, err error)
- func (tx *Tx) Delete(name string) (err error)
- func (tx *Tx) Open(name string) (pb *PinnedBlob, err error)
- func (tx *Tx) OpenPinned(name string) (ret *PinnedBlob, err error)
- func (tx *Tx) OpenPinnedReadOnly(name string) (ret *PinnedBlob, err error)
- func (tx *Tx) Put(name string, b []byte) (err error)
- func (tx *Tx) ReadAll(key string, b []byte) (ret []byte, err error)
- func (tx *Tx) ReadFull(key string, b []byte) (n int, err error)
- func (tx *Tx) SetTag(key, name string, value any) (err error)
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = fs.ErrClosed
var ErrNotFound = errNotFound{}
Functions ¶
func InitSchema ¶
func TestingTempCachePath ¶ added in v0.5.0
Types ¶
type Blob ¶
type Blob struct {
// contains filtered or unexported fields
}
Blobs are references to a name in a Cache that are looked up when its methods are used. They should not be when inside a Tx.
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func NewCache ¶
func NewCache(opts NewCacheOpts) (_ *Cache, err error)
func TestingNewCache ¶ added in v0.5.0
func TestingNewCache(c *qt.C, opts NewCacheOpts) *Cache
func (*Cache) BlobWithLength ¶ added in v0.4.0
Defines a Blob with the given name and length. Nothing is actually written or checked in the DB.
func (*Cache) Create ¶ added in v0.6.0
func (c *Cache) Create(name string, opts CreateOpts) (ret CachePinnedBlob, err error)
Returns a PinnedBlob with its own implied Tx.
func (*Cache) GetCapacity ¶
func (*Cache) NewBlobRef ¶ added in v0.5.0
Defines a Blob with the given name and length. Nothing is actually written or checked in the DB.
func (*Cache) OpenPinnedReadOnly ¶ added in v0.5.0
func (c *Cache) OpenPinnedReadOnly(name string) (ret CachePinnedBlob, err error)
Returns a PinnedBlob. The item must already exist. You must call PinnedBlob.Close when done with it.
func (*Cache) OpenWithLength ¶
Deprecated. Use BlobWithLength.
type CachePinnedBlob ¶ added in v0.6.0
type CachePinnedBlob struct { // An item that exists inside its own transaction. *PinnedBlob // contains filtered or unexported fields }
func (CachePinnedBlob) Close ¶ added in v0.6.0
func (me CachePinnedBlob) Close() (err error)
type CreateOpts ¶ added in v0.5.0
type CreateOpts struct {
Length int64
}
type ErrUnexpectedJournalMode ¶
type ErrUnexpectedJournalMode struct {
JournalMode string
}
func (ErrUnexpectedJournalMode) Error ¶
func (me ErrUnexpectedJournalMode) Error() string
type InitConnOpts ¶
type InitConnOpts struct { SetSynchronous int SetJournalMode string MmapSizeOk bool // If false, a package-specific default will be used. MmapSize int64 // If MmapSizeOk is set, use sqlite default if < 0, otherwise this value. SetLockingMode string // Applies sqlite3 pragma cache_size. If negative it's the number of kibibytes. If positive, // it's the number of pages. int64 might be too large for the true range of values permissible. CacheSize g.Option[int64] // Maximum length of a blob or text value. LengthLimit g.Option[int] JournalSizeLimit g.Option[int64] MaxPageCount g.Option[uint32] }
type InitDbOpts ¶
type InitDbOpts struct { SetAutoVacuum g.Option[string] RequireAutoVacuum g.Option[any] PageSize int DontInitSchema bool NoTriggers bool // If non-zero, overrides the existing setting. Less than zero is unlimited. Capacity int64 }
Fields are in order of how they should be used during initialization.
type NewCacheOpts ¶
type NewCacheOpts struct { NewConnOpts InitDbOpts InitConnOpts // If not-nil, this will be closed if the sqlite busy handler is invoked while initializing the // Cache. ConnBlockedOnBusy *chan struct{} Logger log.Logger }
func TestingDefaultCacheOpts ¶ added in v0.5.0
func TestingDefaultCacheOpts(tb testing.TB) (ret NewCacheOpts)
type NewConnOpts ¶
type NewConnOpts struct { // See https://www.sqlite.org/c3ref/open.html. NB: "If the filename is an empty string, then a // private, temporary on-disk database will be created. This private database will be // automatically deleted as soon as the database connection is closed." Path string Memory bool // sqlite3 has a default limit of 1GB. Due to integer types used internally, I think it's not // possible to go over 2GiB-1. MaxBlobSize g.Option[maxBlobSizeType] }
type PinnedBlob ¶
type PinnedBlob struct {
// contains filtered or unexported fields
}
Wraps a specific sqlite.Blob instance, when we don't want to dive into the cache to refetch blobs. Until Closed, PinnedBlob holds a transaction open on the Cache.
func (*PinnedBlob) Close ¶ added in v0.5.0
func (pb *PinnedBlob) Close() error
func (*PinnedBlob) LastUsed ¶ added in v0.5.0
func (pb *PinnedBlob) LastUsed() (lastUsed time.Time, err error)
func (*PinnedBlob) LengthErr ¶ added in v0.6.0
func (pb *PinnedBlob) LengthErr() (_ int64, err error)
This is very cheap for this type.
type SqliteStmt ¶ added in v0.4.2
type Tx ¶ added in v0.5.0
type Tx struct {
// contains filtered or unexported fields
}
func (*Tx) Create ¶ added in v0.5.0
func (tx *Tx) Create(name string, opts CreateOpts) (pb *PinnedBlob, err error)
func (*Tx) OpenPinned ¶ added in v0.5.0
func (tx *Tx) OpenPinned(name string) (ret *PinnedBlob, err error)
Returns a PinnedBlob. The item must already exist. You must call PinnedBlob.Close when done with it.
func (*Tx) OpenPinnedReadOnly ¶ added in v0.5.0
func (tx *Tx) OpenPinnedReadOnly(name string) (ret *PinnedBlob, err error)
Returns a PinnedBlob. The item must already exist. You must call PinnedBlob.Close when done with it.