cache

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrStillInUse means an object is still in use.
	ErrStillInUse = errors.New("still in use")
	// ErrNotFound is returned when the requested item is not found.
	ErrNotFound = memdb.ErrNotFound
)

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// InsertRoute adds or updates route to cache.
	InsertRoute(*v1.Route) error
	// InsertSSL adds or updates ssl to cache.
	InsertSSL(*v1.Ssl) error
	// InsertUpstream adds or updates upstream to cache.
	InsertUpstream(*v1.Upstream) error
	// InsertStreamRoute adds or updates stream_route to cache.
	InsertStreamRoute(*v1.StreamRoute) error
	// InsertGlobalRule adds or updates global_rule to cache.
	InsertGlobalRule(*v1.GlobalRule) error
	// InsertConsumer adds or updates consumer to cache.
	InsertConsumer(*v1.Consumer) error
	// InsertSchema adds or updates schema to cache.
	InsertSchema(*v1.Schema) error
	// InsertPluginConfig adds or updates plugin_config to cache.
	InsertPluginConfig(*v1.PluginConfig) error

	InsertUpstreamServiceRelation(*v1.UpstreamServiceRelation) error

	// GetRoute finds the route from cache according to the primary index (id).
	GetRoute(string) (*v1.Route, error)
	// GetSSL finds the ssl from cache according to the primary index (id).
	GetSSL(string) (*v1.Ssl, error)
	// GetUpstream finds the upstream from cache according to the primary index (id).
	GetUpstream(string) (*v1.Upstream, error)
	// GetStreamRoute finds the stream_route from cache according to the primary index (id).
	GetStreamRoute(string) (*v1.StreamRoute, error)
	// GetGlobalRule finds the global_rule from cache according to the primary index (id).
	GetGlobalRule(string) (*v1.GlobalRule, error)
	// GetConsumer finds the consumer from cache according to the primary index (username).
	GetConsumer(string) (*v1.Consumer, error)
	// GetSchema finds the scheme from cache according to the primary index (name).
	GetSchema(string) (*v1.Schema, error)
	// GetPluginConfig finds the plugin_config from cache according to the primary index (id).
	GetPluginConfig(string) (*v1.PluginConfig, error)
	// GetUpstreamServiceRelation finds the upstream_service from cache according to the primary index (service name).
	GetUpstreamServiceRelation(string) (*v1.UpstreamServiceRelation, error)

	// ListRoutes lists all routes in cache.
	ListRoutes() ([]*v1.Route, error)
	// ListSSL lists all ssl objects in cache.
	ListSSL() ([]*v1.Ssl, error)
	// ListUpstreams lists all upstreams in cache.
	ListUpstreams() ([]*v1.Upstream, error)
	// ListStreamRoutes lists all stream_route in cache.
	ListStreamRoutes() ([]*v1.StreamRoute, error)
	// ListGlobalRules lists all global_rule objects in cache.
	ListGlobalRules() ([]*v1.GlobalRule, error)
	// ListConsumers lists all consumer objects in cache.
	ListConsumers() ([]*v1.Consumer, error)
	// ListSchema lists all schema in cache.
	ListSchema() ([]*v1.Schema, error)
	// ListPluginConfigs lists all plugin_config in cache.
	ListPluginConfigs() ([]*v1.PluginConfig, error)

	ListUpstreamServiceRelation() ([]*v1.UpstreamServiceRelation, error)

	// DeleteRoute deletes the specified route in cache.
	DeleteRoute(*v1.Route) error
	// DeleteSSL deletes the specified ssl in cache.
	DeleteSSL(*v1.Ssl) error
	// DeleteUpstream deletes the specified upstream in cache.
	DeleteUpstream(*v1.Upstream) error
	// DeleteStreamRoute deletes the specified stream_route in cache.
	DeleteStreamRoute(*v1.StreamRoute) error
	// DeleteGlobalRule deletes the specified stream_route in cache.
	DeleteGlobalRule(*v1.GlobalRule) error
	// DeleteConsumer deletes the specified consumer in cache.
	DeleteConsumer(*v1.Consumer) error
	// DeleteSchema deletes the specified schema in cache.
	DeleteSchema(*v1.Schema) error
	// DeletePluginConfig deletes the specified plugin_config in cache.
	DeletePluginConfig(*v1.PluginConfig) error

	CheckUpstreamReference(*v1.Upstream) error
	CheckPluginConfigReference(*v1.PluginConfig) error
	DeleteUpstreamServiceRelation(*v1.UpstreamServiceRelation) error
}

Cache defines the necessary behaviors that the cache object should have. Note this interface is for APISIX, not for generic purpose, it supports standard APISIX resources, i.e. Route, Upstream, and SSL. Cache implementations should copy the target objects before/after read/write operations for the sake of avoiding data corrupted by other writers.

func NewMemDBCache

func NewMemDBCache() (Cache, error)

NewMemDBCache creates a Cache object backs with a memory DB.

func NewNoopDBCache added in v1.7.0

func NewNoopDBCache() (Cache, error)

NewMemDBCache creates a Cache object backs with a memory DB.

Jump to

Keyboard shortcuts

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