cache

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const FEATURES_CACHE_TABLE string = "pmtiles_features"

Variables

This section is empty.

Functions

func CacheFeatureCollection

func CacheFeatureCollection(ctx context.Context, m CacheManager, fc *geojson.FeatureCollection) ([]string, error)

func CacheFeatures

func CacheFeatures(ctx context.Context, m CacheManager, features [][]byte) ([]string, error)

func CacheManagerSchemes

func CacheManagerSchemes() []string

Schemes returns the list of schemes that have been registered.

func FeatureId

func FeatureId(feature *geojson.Feature) (string, error)

func FeatureIdFromBytes

func FeatureIdFromBytes(body []byte) (string, error)

func RegisterCacheManager

func RegisterCacheManager(ctx context.Context, scheme string, init_func CacheManagerInitializationFunc) error

RegisterCacheManager registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `CacheManager` instances by the `NewCacheManager` method.

func UniqueFeatures

func UniqueFeatures(ctx context.Context, features []*geojson.Feature) ([][]byte, error)

func UnmarshalFeatureCache

func UnmarshalFeatureCache(ctx context.Context, fc *FeatureCache) (*geojson.Feature, error)

Types

type CacheManager

type CacheManager interface {
	CacheFeature(context.Context, []byte) (*FeatureCache, error)
	GetFeatureCache(context.Context, string) (*FeatureCache, error)
	Close() error
}

func NewCacheManager

func NewCacheManager(ctx context.Context, uri string) (CacheManager, error)

NewCacheManager returns a new `CacheManager` instance configured by 'uri'. The value of 'uri' is parsed as a `url.URL` and its scheme is used as the key for a corresponding `CacheManagerInitializationFunc` function used to instantiate the new `CacheManager`. It is assumed that the scheme (and initialization function) have been registered by the `RegisterCacheManager` method.

func NewDocstoreCacheManager

func NewDocstoreCacheManager(ctx context.Context, uri string) (CacheManager, error)

func NewDocstoreCacheManagerWithOptions

func NewDocstoreCacheManagerWithOptions(ctx context.Context, opts *DocstoreCacheManagerOptions) CacheManager

func NewSQLCacheManager

func NewSQLCacheManager(ctx context.Context, uri string) (CacheManager, error)

type CacheManagerInitializationFunc

type CacheManagerInitializationFunc func(ctx context.Context, uri string) (CacheManager, error)

CacheManagerInitializationFunc is a function defined by individual cache_manager package and used to create an instance of that cache_manager

type DocstoreCacheManager

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

func (*DocstoreCacheManager) CacheFeature

func (m *DocstoreCacheManager) CacheFeature(ctx context.Context, body []byte) (*FeatureCache, error)

func (*DocstoreCacheManager) Close

func (m *DocstoreCacheManager) Close() error

func (*DocstoreCacheManager) GetFeatureCache

func (m *DocstoreCacheManager) GetFeatureCache(ctx context.Context, id string) (*FeatureCache, error)

type DocstoreCacheManagerOptions

type DocstoreCacheManagerOptions struct {
	FeatureCollection *docstore.Collection
	CacheTTL          int
}

type FeatureCache

type FeatureCache struct {
	Created int64  `json:"created"`
	Id      string `json:"id"` // this is a string rather than int64 because it might include an alt label
	Body    string `json:"body"`
}

func NewFeatureCache

func NewFeatureCache(body []byte) (*FeatureCache, error)

type SQLCacheManager

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

func (*SQLCacheManager) CacheFeature

func (m *SQLCacheManager) CacheFeature(ctx context.Context, body []byte) (*FeatureCache, error)

func (*SQLCacheManager) Close

func (m *SQLCacheManager) Close() error

func (*SQLCacheManager) GetFeatureCache

func (m *SQLCacheManager) GetFeatureCache(ctx context.Context, id string) (*FeatureCache, error)

type SQLCacheManagerOptions

type SQLCacheManagerOptions struct {
	FeatureCollection *sql.DB
}

type SQLFeaturesTable added in v0.5.1

type SQLFeaturesTable struct {
	database_sql.Table
}

func (*SQLFeaturesTable) IndexRecord added in v0.5.1

func (t *SQLFeaturesTable) IndexRecord(ctx context.Context, db *sql.DB, i interface{}) error

func (*SQLFeaturesTable) InitializeTable added in v0.5.1

func (t *SQLFeaturesTable) InitializeTable(ctx context.Context, db *sql.DB) error

func (*SQLFeaturesTable) Name added in v0.5.1

func (t *SQLFeaturesTable) Name() string

func (*SQLFeaturesTable) Schema added in v0.5.1

func (t *SQLFeaturesTable) Schema(db *sql.DB) (string, error)

Jump to

Keyboard shortcuts

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