Documentation
¶
Overview ¶
usage:
import (
"log/slog" "github.com/unkn0wn-root/cascache" "github.com/unkn0wn-root/cascache/codec" "github.com/unkn0wn-root/cascache/genstore" "github.com/unkn0wn-root/cascache/hooks/async" "github.com/unkn0wn-root/cascache/hooks/slog"
)
raw := sloghook.New(slog.Default(), sloghook.Options{
SelfHealEvery: 10, // sample logs: ~every 10th self-heal
BulkRejectEvery: 1, // log every bulk rejection
})
hooks := asynchook.New(raw, 1, 1000) // 1 worker; queue 1000 events defer hooks.Close()
cache, _ := cascache.New[User](cascache.Options[User]{
Namespace: "app:prod:user",
Provider: provider,
Codec: codec.JSON[User]{},
GenStore: genstore.NewRedisGenStoreWithTTL(rdb, "app:prod:user", 24*time.Hour),
Hooks: hooks, // or `raw` if you don’t want async
})
Index ¶
- type Hooks
- func (h *Hooks) BulkRejected(ns string, n int, r cascache.BulkRejectReason)
- func (h *Hooks) Close()
- func (h *Hooks) GenBumpError(k string, err error)
- func (h *Hooks) GenSnapshotError(n int, err error)
- func (h *Hooks) InvalidateOutage(k string, be, de error)
- func (h *Hooks) LocalGenWithBulk()
- func (h *Hooks) ProviderSetRejected(k string, b bool)
- func (h *Hooks) SelfHealSingle(k string, r cascache.SelfHealReason)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
func (*Hooks) BulkRejected ¶
func (h *Hooks) BulkRejected(ns string, n int, r cascache.BulkRejectReason)
func (*Hooks) GenBumpError ¶
func (*Hooks) GenSnapshotError ¶
func (*Hooks) InvalidateOutage ¶
func (*Hooks) LocalGenWithBulk ¶
func (h *Hooks) LocalGenWithBulk()
func (*Hooks) ProviderSetRejected ¶
func (*Hooks) SelfHealSingle ¶
func (h *Hooks) SelfHealSingle(k string, r cascache.SelfHealReason)
Click to show internal directories.
Click to hide internal directories.