s3cache

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2017 License: MIT Imports: 12 Imported by: 0

README

S3Cache

s3cache is an abstraction on top of Amazon Web Services (AWS) Simple Storage Service (S3) which implements the tegola cache interface. To use it, add the following minimum config to your tegola config file:

[cache]
type="s3"   
bucket="tegola-test-data"

Properties

The s3cache config supports the following properties:

  • bucket (string): [Required] the name of the S3 bucket to use.
  • basepath (string): [Optional] a path prefix added to all cache operations inside of the S3 bucket. helpful so a bucket does not need to be dedicated to only this cache.
  • region (string): [Optional] the region the bucket is in. Defaults to 'us-east-1'
  • aws_access_key_id (string): [Optional] the AWS access key id to use.
  • aws_secret_access_key (string): [Optional] the AWS secret access key to use.
  • max_zoom (int): [Optional] the max zoom the cache should cache to. After this zoom, Set() calls will return before doing work.

Credential chain

If the aws_access_key_id and aws_secret_access_key are not set, then the credential provider chain will be used. The provider chain supports multiple methods for passing credentials, one of which is setting environment variables. For example:

$ export AWS_REGION=us-west-2
$ export AWS_ACCESS_KEY_ID=YOUR_AKID
$ export AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY

Testing

Testing is designed to work against a live S3 bucket. To run the s3 cache tests, the following environment variables need to be set:

$ export RUN_S3_TESTS=yes
$ export AWS_TEST_BUCKET=YOUR_TEST_BUCKET_NAME
$ export AWS_REGION=TEST_BUCKET_REGION
$ export AWS_ACCESS_KEY_ID=YOUR_AKID
$ export AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY

Documentation

Index

Constants

View Source
const (
	//	required
	ConfigKeyBucket = "bucket"
	//	optional
	ConfigKeyBasepath       = "basepath"
	ConfigKeyMaxZoom        = "max_zoom"
	ConfigKeyRegion         = "region" //	defaults to "us-east-1"
	ConfigKeyAWSAccessKeyID = "aws_access_key_id"
	ConfigKeyAWSSecretKey   = "aws_secret_access_key"
)
View Source
const CacheType = "s3"
View Source
const (
	DefaultRegion = "us-east-1"
)

Variables

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

Functions

func New

func New(config map[string]interface{}) (cache.Interface, error)

Types

type S3Cache

type S3Cache struct {
	//	Bucket is the name of the s3 bucket to operate on
	Bucket string

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

	//	MaxZoom determins 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 s3 client. it's expected the client
	//	has an active session and read, write, delete permissions have been checked
	Client *s3.S3
}

func (*S3Cache) Get

func (s3c *S3Cache) Get(key *cache.Key) ([]byte, bool, error)

func (*S3Cache) Purge

func (s3c *S3Cache) Purge(key *cache.Key) error

func (*S3Cache) Set

func (s3c *S3Cache) 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