package timecache
Import Path
github.com/libp2p/go-libp2p-pubsub/timecache (on go.dev)
Dependency Relation
imports 3 packages, and imported by one package
Package-Level Type Names (total 4)
FirstSeenCache is a time cache that only marks the expiry of a message when first added.
(*FirstSeenCache) Add(s string) bool
(*FirstSeenCache) Done()
(*FirstSeenCache) Has(s string) bool
*FirstSeenCache : TimeCache
LastSeenCache is a time cache that extends the expiry of a seen message when added
or checked for presence with Has..
(*LastSeenCache) Add(s string) bool
(*LastSeenCache) Done()
(*LastSeenCache) Has(s string) bool
*LastSeenCache : TimeCache
Stategy is the TimeCache expiration strategy to use.
func NewTimeCacheWithStrategy(strategy Strategy, ttl time.Duration) TimeCache
func github.com/libp2p/go-libp2p-pubsub.WithSeenMessagesStrategy(strategy Strategy) pubsub.Option
const Strategy_FirstSeen
const Strategy_LastSeen
var github.com/libp2p/go-libp2p-pubsub.TimeCacheStrategy
TimeCache is a cahe of recently seen messages (by id).
Add adds an id into the cache, if it is not already there.
Returns true if the id was newly added to the cache.
Depending on the implementation strategy, it may or may not update the expiry of
an existing entry.
Done signals that the user is done with this cache, which it may stop background threads
and relinquish resources.
Has checks the cache for the presence of an id.
Depending on the implementation strategy, it may or may not update the expiry of
an existing entry.
*FirstSeenCache
*LastSeenCache
func NewTimeCache(ttl time.Duration) TimeCache
func NewTimeCacheWithStrategy(strategy Strategy, ttl time.Duration) TimeCache
Package-Level Functions (total 2)
NewTimeCache defaults to the original ("first seen") cache implementation
func NewTimeCacheWithStrategy(strategy Strategy, ttl time.Duration) TimeCache
Package-Level Constants (total 2)
Strategy_FirstSeen expires an entry from the time it was added.
Stategy_LastSeen expires an entry from the last time it was touched by an Add or Has.
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |