asynchook

package
v1.2.1 Latest Latest
Warning

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

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

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, 24*time.Hour),
    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) BulkRejected

func (h *Hooks) BulkRejected(ns string, n int, r cascache.BulkRejectReason)

func (*Hooks) Close

func (h *Hooks) Close()

func (*Hooks) GenBumpError

func (h *Hooks) GenBumpError(k genstore.CacheKey, err error)

func (*Hooks) GenSnapshotError

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

func (*Hooks) InvalidateOutage

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

func (*Hooks) LocalGenWithBulk

func (h *Hooks) LocalGenWithBulk()

func (*Hooks) ProviderSetRejected

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

func (*Hooks) SelfHealSingle

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

Jump to

Keyboard shortcuts

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