versionvector

package
v0.0.0-...-2e8e066 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is a threadsafe expiring cache of version vectors that is capable of passing through cache misses to a lookup function.

func NewCache

func NewCache(duration time.Duration, lookup Lookup) *Cache

NewCache returns a new version vector cache with the given cache duration and value lookup function.

func (*Cache) Close

func (cache *Cache) Close()

Close will release any resources consumed by the cache and its contents. It will also prevent further use of the cache.

func (*Cache) Evict

func (cache *Cache) Evict()

Evict will expuge all existing values from the cache. Outstanding lookups that are still pending will not be affected.

func (*Cache) Lookup

func (cache *Cache) Lookup(ctx context.Context, guid uuid.UUID, tracker dfsr.Tracker) (vector *Vector, call callstat.Call, err error)

Lookup returns the cached vector for the given GUID if it exists in the cache and has not expired. If the cached value is missing or expired, a lookup will be performed.

If the cache has been closed then ErrClosed will be returned.

func (*Cache) Set

func (cache *Cache) Set(guid uuid.UUID, vector *Vector, call callstat.Call)

Set adds the vector to the cache for the given GUID. If a value already exists in the cache for that GUID, the existing value is replaced.

If the cache has been closed then Set will do nothing.

func (*Cache) Value

func (cache *Cache) Value(guid uuid.UUID) (vector *Vector, call callstat.Call, ok bool)

Value returns the cached vector for the given GUID if it exists in the cache and has not expired. If the cached value is missing or expired, ok will be false.

If the cache has been closed then ok will be false.

type Lookup

type Lookup func(ctx context.Context, guid uuid.UUID, tracker dfsr.Tracker) (vector *Vector, call callstat.Call, err error)

Lookup defines a version vector lookup function.

type Vector

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

Vector represents version vector data from a replication group member.

func New

func New(sa *ole.SafeArrayConversion) (vector *Vector, err error)

New returns a new version vector for the given safe array of data.

func (*Vector) Close

func (vector *Vector) Close()

Close will release any resources consumed by the version vector. It should be called when finished with the version vector.

func (*Vector) Data

func (vector *Vector) Data() (sa *ole.SafeArrayConversion)

Data returns the version vector data as a safe array.

func (*Vector) Duplicate

func (vector *Vector) Duplicate() (duplicate *Vector, err error)

Duplicate will return a duplicate of the vector that does not share any memory with the original.

Jump to

Keyboard shortcuts

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