cache

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cache provides caching mechanisms for transaction deduplication and tracking.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DuplicateCache

type DuplicateCache struct {
	Transaction *ttlcache.Cache[string, time.Time]
}

DuplicateCache tracks duplicate transactions within a time window.

func NewDuplicateCache

func NewDuplicateCache() *DuplicateCache

NewDuplicateCache creates a new DuplicateCache instance.

func (*DuplicateCache) Start

func (d *DuplicateCache) Start()

Start begins the cache background processes.

func (*DuplicateCache) Stop

func (d *DuplicateCache) Stop()

Stop stops the cache.

type Metrics

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

Metrics provides Prometheus metrics for cache operations.

func NewMetrics

func NewMetrics(namespace string) *Metrics

NewMetrics creates a new Metrics instance.

func NewMetricsWithRegisterer added in v0.2.0

func NewMetricsWithRegisterer(namespace string, registerer prometheus.Registerer) *Metrics

NewMetricsWithRegisterer creates a new Metrics instance with a custom registerer.

func (*Metrics) SetSharedEvictions

func (m *Metrics) SetSharedEvictions(count uint64, store string)

SetSharedEvictions sets the shared evictions metric.

func (*Metrics) SetSharedHits

func (m *Metrics) SetSharedHits(count uint64, store string)

SetSharedHits sets the shared hits metric.

func (*Metrics) SetSharedInsertions

func (m *Metrics) SetSharedInsertions(count uint64, store string)

SetSharedInsertions sets the shared insertions metric.

func (*Metrics) SetSharedMisses

func (m *Metrics) SetSharedMisses(count uint64, store string)

SetSharedMisses sets the shared misses metric.

type SentCache added in v0.2.0

type SentCache struct {
	Transaction *ttlcache.Cache[string, time.Time]
	// contains filtered or unexported fields
}

SentCache tracks transactions that have been successfully sent to targets to prevent duplicate forwarding across all source peers

func NewSentCache added in v0.2.0

func NewSentCache() *SentCache

NewSentCache creates a new sent transaction cache

func NewSentCacheWithRegisterer added in v0.2.0

func NewSentCacheWithRegisterer(registerer prometheus.Registerer) *SentCache

NewSentCacheWithRegisterer creates a new sent transaction cache with a custom registerer. Pass nil to skip metrics registration (useful for tests).

func (*SentCache) Start added in v0.2.0

func (s *SentCache) Start(ctx context.Context) error

Start begins the sent cache background processes

func (*SentCache) Stop added in v0.2.0

func (s *SentCache) Stop()

Stop stops the sent cache

type SharedCache

type SharedCache struct {
	Transaction *ttlcache.Cache[string, *types.Transaction]
	Sent        *SentCache
	// contains filtered or unexported fields
}

SharedCache provides a shared transaction cache across peers.

func NewSharedCache

func NewSharedCache() *SharedCache

NewSharedCache creates a new SharedCache instance.

func NewSharedCacheWithRegisterer added in v0.2.0

func NewSharedCacheWithRegisterer(registerer prometheus.Registerer) *SharedCache

NewSharedCacheWithRegisterer creates a new SharedCache instance with a custom registerer. Pass nil to skip metrics registration (useful for tests).

func (*SharedCache) Start

func (d *SharedCache) Start(ctx context.Context) error

Start begins the cache background processes.

func (*SharedCache) Stop added in v0.2.0

func (d *SharedCache) Stop()

Stop stops the cache background processes.

Jump to

Keyboard shortcuts

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