cacheinv

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 8 Imported by: 0

README

Simple & Efficient Cache Invalidator

Coverage Status

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// GetServerIDs ...
	GetServerIDs() []int64

	// GetServerName ...
	GetServerName(serverID int64) string

	// DeleteCacheKeys ...
	DeleteCacheKeys(ctx context.Context, serverID int64, keys []string) error
}

Client ...

type InvalidateEvent

type InvalidateEvent struct {
	ID   int64         `db:"id"`
	Seq  sql.NullInt64 `db:"seq"`
	Data string        `db:"data"`
}

InvalidateEvent ...

func (InvalidateEvent) GetID

func (e InvalidateEvent) GetID() uint64

GetID returns the event id

func (InvalidateEvent) GetSequence

func (e InvalidateEvent) GetSequence() uint64

GetSequence returns the event sequence number, = 0 if sequence is null

func (InvalidateEvent) GetSize

func (e InvalidateEvent) GetSize() uint64

GetSize returns the approximate size (in bytes) of the event, for limit batch size by event data size using WithSubscriberSizeLimit for configuring this limit

type InvalidatorJob

type InvalidatorJob struct {
	// contains filtered or unexported fields
}

InvalidatorJob ...

func NewInvalidatorJob

func NewInvalidatorJob(repo Repository, client Client, options ...Option) *InvalidatorJob

NewInvalidatorJob ...

func (*InvalidatorJob) Notify

func (j *InvalidatorJob) Notify()

Notify ...

func (*InvalidatorJob) Run

func (j *InvalidatorJob) Run()

Run ...

func (*InvalidatorJob) Shutdown

func (j *InvalidatorJob) Shutdown()

Shutdown ...

type Option

type Option func(conf *jobConfig)

Option ...

func WithRetentionOptions

func WithRetentionOptions(options ...eventx.RetentionOption) Option

WithRetentionOptions ...

func WithRetryConsumerOptions

func WithRetryConsumerOptions(options ...eventx.RetryConsumerOption) Option

WithRetryConsumerOptions ...

func WithRunnerOptions

func WithRunnerOptions(options ...eventx.Option) Option

WithRunnerOptions ...

type Repository

type Repository interface {
	eventx.Repository[InvalidateEvent]

	// GetMinSequence returns the min sequence number of all events (except events with null sequence numbers)
	// returns null if no events with sequence number existed
	GetMinSequence(ctx context.Context) (sql.NullInt64, error)

	// DeleteEventsBefore deletes events with sequence number < *beforeSeq*
	DeleteEventsBefore(ctx context.Context, beforeSeq uint64) error

	// GetLastSequence get from invalidate_offsets table
	GetLastSequence(ctx context.Context, serverName string) (sql.NullInt64, error)
	// SetLastSequence upsert into invalidate_offsets table
	SetLastSequence(ctx context.Context, serverName string, seq int64) error
}

Repository ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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