gcscaching

package
v0.0.0-...-cfd7a7c Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Caching wrappers around GCS to eliminate round trips.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFastStatBucket

func NewFastStatBucket(
	ttl time.Duration,
	cache StatCache,
	clock timeutil.Clock,
	wrapped gcs.Bucket,
	negcache bool) (b gcs.Bucket)

Create a bucket that caches object records returned by the supplied wrapped bucket. Records are invalidated when modifications are made through this bucket, and after the supplied TTL. Parameter 'negcache' enables negative results caching, i.e. when StatObject returns NotFound, this result will be cached.

Types

type StatCache

type StatCache interface {
	// Insert an entry for the given object record.
	//
	// In order to help cope with caching of arbitrarily out of date (i.e.
	// inconsistent) object listings, entry will not replace any positive entry
	// with a newer generation number, or with an equivalent generation number
	// but newer metadata generation number. We have no choice, however, but to
	// replace negative entries.
	//
	// The entry will expire after the supplied time.
	Insert(o *gcs.Object, expiration time.Time)

	// Set up a negative entry for the given name, indicating that the name
	// doesn't exist. Overwrite any existing entry for the name, positive or
	// negative.
	AddNegativeEntry(name string, expiration time.Time)

	// Erase the entry for the given object name, if any.
	Erase(name string)

	// Return the current entry for the given name, or nil if there is a negative
	// entry. Return hit == false when there is neither a positive nor a negative
	// entry, or the entry has expired according to the supplied current time.
	LookUp(name string, now time.Time) (hit bool, o *gcs.Object)

	// Panic if any internal invariants have been violated. The careful user can
	// arrange to call this at crucial moments.
	CheckInvariants()
}

A cache mapping from name to most recent known record for the object of that name. External synchronization must be provided.

func NewStatCache

func NewStatCache(capacity int) (sc StatCache)

Create a new stat cache that holds the given number of entries, which must be positive.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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