cache

package
v5.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

package cache provides functions for saving IIIF files to supported locations, including disk, memory, blob, and Amazon S3.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlobCache

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

A BlobCache is a Cache that includes attributes specific to a blob such as the bucket_uri and acl configuration.

func (*BlobCache) Exists

func (bc *BlobCache) Exists(uri string) bool

Exists returns a bool set to true if the configured bucket exists.

func (*BlobCache) Get

func (bc *BlobCache) Get(uri string) ([]byte, error)

Get reads data from a BlobCache location.

func (*BlobCache) Set

func (bc *BlobCache) Set(uri string, body []byte) error

Set writes data to a BlobCache location.

func (*BlobCache) Unset

func (bc *BlobCache) Unset(uri string) error

Unset deletes data from a BlobCache location.

type Cache

type Cache interface {
	Exists(string) bool
	Get(string) ([]byte, error)
	Set(string, []byte) error
	Unset(string) error
}

A Cache is a representation of a cache location.

func NewBlobCache

func NewBlobCache(config iiifconfig.CacheConfig) (Cache, error)

NewBlobCache returns a NewBlobCacheFromURI.

func NewBlobCacheFromURI

func NewBlobCacheFromURI(uri string) (Cache, error)

NewBlobCacheFromURI returns a BlobCache using the GoCloud package.

func NewCacheFromConfig

func NewCacheFromConfig(config iiifconfig.CacheConfig) (Cache, error)

NewCacheFromConfig returns a Cache object depending on the type of cache requested. Cache types can be blob, disk, memory, s3 or s3blob.

func NewDerivativesCacheFromConfig

func NewDerivativesCacheFromConfig(config *iiifconfig.Config) (Cache, error)

NewDerivativesCacheFromConfig returns a NewCacheFromConfig.

func NewDiskCache

func NewDiskCache(cfg config.CacheConfig) (Cache, error)

NewDiskCache returns a NewBlobCacheFromURI for a local files system location.

func NewImagesCacheFromConfig

func NewImagesCacheFromConfig(config *iiifconfig.Config) (Cache, error)

NewImagesCacheFromConfig returns a NewCacheFromConfig.

func NewS3Cache

func NewS3Cache(cfg iiifconfig.CacheConfig) (Cache, error)

NewS3Cache returns a NewBlobCacheFromURI with a constructed blob uri.

type MemoryCache

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

A MemoryCache represents a cache location in memory.

func NewMemoryCache

func NewMemoryCache(cfg iiifconfig.CacheConfig) (*MemoryCache, error)

NewMemoryCache returns a pointer to a MemoryCache

func (*MemoryCache) Exists

func (mc *MemoryCache) Exists(key string) bool

Exists returns a bool set to true if the configured memory location exists.

func (*MemoryCache) Get

func (mc *MemoryCache) Get(key string) ([]byte, error)

Get reads data from a memory location.

func (*MemoryCache) OnEvicted

func (mc *MemoryCache) OnEvicted(key string, value interface{})

func (*MemoryCache) Set

func (mc *MemoryCache) Set(key string, data []byte) error

Set writes data to a memory location.

func (*MemoryCache) Unset

func (mc *MemoryCache) Unset(key string) error

Unset deletes data from a memory location.

type NullCache

type NullCache struct {
	Cache
}

A NullCache represents a Cache.

func NewNullCache

func NewNullCache(cfg config.CacheConfig) (*NullCache, error)

NewNullCache returns a pointer to a NullCache.

func (*NullCache) Exists

func (c *NullCache) Exists(rel_path string) bool

Exists is always false for a NullCache.

func (*NullCache) Get

func (c *NullCache) Get(rel_path string) ([]byte, error)

Get returns nil and an error message.

func (*NullCache) Set

func (c *NullCache) Set(rel_path string, body []byte) error

Set returns nil.

func (*NullCache) Unset

func (c *NullCache) Unset(rel_path string) error

Unset returns nil.

Jump to

Keyboard shortcuts

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