gcs

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 9 Imported by: 0

README

Google Cloud Storage Cache

GCS cache is an abstraction on top of Google Cloud Storage (GCS) which implements the tegola cache interface. To use it, you need to configure cache as the example below:

[cache]
# required
type="gcs"
bucket="your_bucket_name"   # Bucket is the name of the GCS bucket to operate on

# optional
basepath="tegola"           # Basepath is a path prefix added to all cache operations inside of the GCS bucket
max_zoom=8                  # MaxZoom determines the max zoom the cache to persist.

The credentials (service account and project_id) are handled by the GOOGLE_APPLICATION_CREDENTIALS environment variable.

Documentation

Index

Constants

View Source
const (
	// required
	ConfigKeyBucketName = "bucket"

	// optional
	ConfigKeyBasepath = "basepath"
	ConfigKeyMaxZoom  = "max_zoom"
)
View Source
const CacheType = "gcs"

Variables

View Source
var (
	ErrMissingBucket = errors.New("cache_gcs: missing required param 'bucket'")
)

Functions

func New

func New(config dict.Dicter) (cache.Interface, error)

Types

type GCSCache

type GCSCache struct {

	// Context
	Ctx context.Context

	// Bucket is the name of the GCS bucket to operate on
	BucketName string

	// Basepath is a path prefix added to all cache operations inside of the GCS bucket
	// helpful so a bucket does not need to be dedicated to only this cache
	Basepath string

	// MaxZoom determines the max zoom the cache to persist. Beyond this
	// zoom, cache Set() calls will be ignored. This is useful if the cache
	// should not be leveraged for higher zooms when data changes often.
	MaxZoom uint

	// client holds a reference to the storage client. it's expected the client
	// has an active session and read, write, delete permissions have been checked
	Client *storage.Client

	// bucket holds a reference to the bucket handle.
	Bucket *storage.BucketHandle
}

func (*GCSCache) Get

func (gcsCache *GCSCache) Get(key *cache.Key) ([]byte, bool, error)

func (*GCSCache) Purge

func (gcsCache *GCSCache) Purge(key *cache.Key) error

func (*GCSCache) Set

func (gcsCache *GCSCache) Set(key *cache.Key, val []byte) error

Jump to

Keyboard shortcuts

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