kv

package
v0.40.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package kv provides the scriptling.runtime.kv library: a thread-safe key-value store (the process-wide default store plus named stores opened with kv.open), backed by snapshotkv. It is independent of the rest of the runtime family, so an application can register it without background tasks or the HTTP server.

Index

Constants

View Source
const LibraryName = "scriptling.runtime.kv"

LibraryName is the name scripts import the library by.

Variables

This section is empty.

Functions

func CloseStore

func CloseStore()

CloseStore closes the system-wide default KV store.

func DefaultDB

func DefaultDB() *snapshotkv.DB

DefaultDB returns the system-wide default store opened by InitStore, or nil when none is open.

func InitStore

func InitStore(path string, log logger.Logger) error

InitStore initializes the system-wide default KV store. If path is empty, the store operates in memory-only mode. A non-nil log receives snapshot save-failure reports; nil keeps the current logger (a stderr console logger by default). Call it before Register: kv.default is bound when the library is built.

func Register

func Register(registrar object.LibraryRegistrar, allowedPaths []string)

Register registers the scriptling.runtime.kv library. allowedPaths restricts where kv.open may create or open a persistent store, as it does for the filesystem libraries: nil leaves stores unrestricted, an empty slice denies every filesystem path. In-memory stores (":memory:name") are always allowed. A path outside the allowed paths is refused with a PermissionError that a script cannot catch.

When scriptling.runtime is also registered with the same registrar the library is reachable as an attribute of it (`rt.kv`) too. Call InitStore first if scripts should have a kv.default store.

func StoreDB

func StoreDB(store object.Object) *snapshotkv.DB

StoreDB returns the underlying snapshotkv.DB for a kv store object, or nil if the object is not a kv store.

Types

This section is empty.

Jump to

Keyboard shortcuts

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