lua

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package lua exposes hex/cache to Lua scripts as the "cache" module.

local cache = require("cache")

local ok, err = cache.set("greeting", "hi")             -- no TTL
local ok, err = cache.set("hot", "value", 60)           -- 60s TTL
local v, hit, err = cache.get("greeting")
local ok = cache.has("greeting")
cache.delete("greeting")
cache.clear()                                            -- driver may refuse
local n, err = cache.increment("counter", 1)

Values are strings on the Lua side; hex/cache stores raw []byte. Structured values should be JSON-encoded before caching — a gopher-json module is on the follow-up list.

Index

Constants

This section is empty.

Variables

View Source
var TypeStub string

TypeStub is the Teal .d.tl source describing the `cache` module.

Functions

This section is empty.

Types

type Bindings

type Bindings struct {
	// Cache is the backend to read/write. Required.
	Cache cache.Cache

	// Context, when non-nil, is used for every cache call.
	// Defaults to context.Background().
	Context context.Context
}

Bindings configures the 'cache' module.

func (*Bindings) Loader

func (b *Bindings) Loader(L *glua.LState) int

Loader is the gopher-lua LGFunction registered against env.PreloadModule("cache", b.Loader).

Jump to

Keyboard shortcuts

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