cache

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: GPL-2.0, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoder

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

func NewEncoder

func NewEncoder(c context.T, maxCacheSize int,
	gcTimer time.Duration) *Encoder

NewEncoder creates a cache.Encoder that maintains a cache of already decoded JSON bytes of events to prevent doubling up of both decoding work and JSON bytes usage for multiple concurrent requests of overlapping events by clients.

func (*Encoder) Get

func (d *Encoder) Get(evId eventid.T) (b []byte, ok bool)

Get retrieves the encoded JSON for a given event if it is cached.

If ok is false, then the caller needs to fetch the event from elsewhere.

func (*Encoder) Put

func (d *Encoder) Put(ev *event.T, js []byte) (j []byte, err error)

Put stores an event's encoded JSON form for access by concurrent client requests. Call this with an event decoded from the database so that concurrent queries that match it can avoid repeated decode/allocate steps.

If the json is available as well, skip re-encoding it. If the event is already in the cache, return the json.

type Event

type Event struct {
	JSON []byte
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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