asynchook

package
v3.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

usage:

import (

"log/slog"

"github.com/unkn0wn-root/cascache/v3"
"github.com/unkn0wn-root/cascache/v3/codec"
"github.com/unkn0wn-root/cascache/v3/hooks/async"
"github.com/unkn0wn-root/cascache/v3/hooks/slog"
cascacheredis "github.com/unkn0wn-root/cascache/v3/redis"

)

raw := sloghook.New(slog.Default(), sloghook.Options{
    SelfHealEvery:   10, // sample logs: ~every 10th self-heal
    BatchRejectEvery: 1,  // log every batch rejection
})

hooks := asynchook.New(raw, 1, 1000) // 1 worker; queue 1000 events defer hooks.Close()

sharedVersionStore, _ := cascacheredis.NewVersionStore(rdb)

cache, _ := cascache.New[User](cascache.Options[User]{
    Namespace: "app:prod:user",
    Provider:  provider,
    Codec:     codec.JSON[User]{},
    VersionStore:  sharedVersionStore,
    Hooks:     hooks, // or `raw` if you don’t want async
})

Index

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 New

func New(inner cascache.Hooks, workers, qlen int) *Hooks

func (*Hooks) BatchRejected

func (h *Hooks) BatchRejected(ns string, n int, r cascache.BatchRejectReason)

func (*Hooks) Close

func (h *Hooks) Close()

func (*Hooks) InvalidateOutage

func (h *Hooks) InvalidateOutage(k string, be, de error)

func (*Hooks) LocalVersionStoreWithBatch

func (h *Hooks) LocalVersionStoreWithBatch()

func (*Hooks) ProviderSetRejected

func (h *Hooks) ProviderSetRejected(k string, b bool)

func (*Hooks) SelfHealSingle

func (h *Hooks) SelfHealSingle(k string, r cascache.SelfHealReason)

func (*Hooks) VersionAdvanceError

func (h *Hooks) VersionAdvanceError(k version.CacheKey, err error)

func (*Hooks) VersionCreateError

func (h *Hooks) VersionCreateError(k version.CacheKey, err error)

func (*Hooks) VersionSnapshotError

func (h *Hooks) VersionSnapshotError(n int, err error)

Jump to

Keyboard shortcuts

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