cache

package
v0.0.0-...-4b56e16 Latest Latest
Warning

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

Go to latest
Published: May 11, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorMissed code.
	ErrorMissed = errors.New("cache: missed")

	// ErrorPtr code.
	ErrorPtr = errors.New("cache: ptr target")

	// ErrorSerialize code.
	ErrorSerialize = errors.New("cache: failed to serialize data")

	// ErrorUnserialize code.
	ErrorUnserialize = errors.New("cache: failed to unserialize data")

	// ErrorTypeMissmatch code.
	ErrorTypeMissmatch = errors.New("cache: return type missmatch")
)
View Source
var FacadeWrapper = &larago.Facade{}

FacadeWrapper for facade.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Has checks if there is such item.
	Has(key string) bool

	// Put value in cache by key.
	Put(key string, value interface{}, duration time.Duration)

	// Forever remembers the value for ever.
	Forever(key string, value interface{})

	// Remember returns value if it was saved, or saves the value from the callback.
	Remember(key string, duration time.Duration, callback func() (interface{}, error), target interface{}) error

	// RememberForever returns value if it was saved, or saves the value from the callback for ever.
	RememberForever(key string, callback func() (interface{}, error), target interface{}) error

	// Get saved value by the key.
	Get(key string, target interface{}) error

	// Pull saved value by the key.
	Pull(key string, target interface{}) error

	// Forget the value.
	Forget(key string)

	// Clear storage.
	Clear()
}

Cache interface

func Facade

func Facade() Cache

Facade for cache.

type CommandCacheClear

type CommandCacheClear struct {
	Repository *Repository
	Logger     *logger.Logger
}

CommandCacheClear for the app.

func (*CommandCacheClear) GetCommand

func (c *CommandCacheClear) GetCommand() cli.Command

GetCommand for the cli to register.

func (*CommandCacheClear) Handle

func (c *CommandCacheClear) Handle(args cli.Args) error

Handle command.

type DatabaseItem

type DatabaseItem struct {
	Key        string `gorm:"not null;unique_index"`
	Value      string `gorm:"type:text"`
	Expiration time.Time
	// contains filtered or unexported fields
}

DatabaseItem to store.

func (*DatabaseItem) TableName

func (s *DatabaseItem) TableName() string

TableName getter.

type DatabaseStore

type DatabaseStore struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

DatabaseStore .

func NewDatabaseStore

func NewDatabaseStore(table string) *DatabaseStore

NewDatabaseStore constructor.

func (*DatabaseStore) Clear

func (s *DatabaseStore) Clear()

Clear storage.

func (*DatabaseStore) Forever

func (s *DatabaseStore) Forever(key string, value interface{}) error

Forever put value in store by key forever.

func (*DatabaseStore) Forget

func (s *DatabaseStore) Forget(key string)

Forget the value.

func (*DatabaseStore) Get

func (s *DatabaseStore) Get(key string, target interface{}) error

Get saved value by the key.

func (*DatabaseStore) Has

func (s *DatabaseStore) Has(key string) bool

Has checks if there is such item.

func (*DatabaseStore) Put

func (s *DatabaseStore) Put(key string, value interface{}, duration time.Duration) error

Put value in cache by key.

type InMemoryStore

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

InMemoryStore .

func NewInMemoryStore

func NewInMemoryStore() *InMemoryStore

NewInMemoryStore .

func (*InMemoryStore) Clear

func (s *InMemoryStore) Clear()

Clear storage.

func (*InMemoryStore) Forever

func (s *InMemoryStore) Forever(key string, value interface{}) error

Forever put value in store by key forever.

func (*InMemoryStore) Forget

func (s *InMemoryStore) Forget(key string)

Forget the value.

func (*InMemoryStore) Get

func (s *InMemoryStore) Get(key string, target interface{}) error

Get saved value by the key.

func (*InMemoryStore) Has

func (s *InMemoryStore) Has(key string) bool

Has checks if there is such item.

func (*InMemoryStore) Put

func (s *InMemoryStore) Put(key string, value interface{}, duration time.Duration) error

Put value in cache by key.

type Repository

type Repository struct {
	Events *EventBus.EventBus
	// contains filtered or unexported fields
}

Repository .

func NewRepository

func NewRepository(store Store) *Repository

NewRepository constructor.

func (*Repository) Clear

func (r *Repository) Clear()

Clear storage.

func (*Repository) Forever

func (r *Repository) Forever(key string, value interface{})

Forever remembers the value for ever.

func (*Repository) Forget

func (r *Repository) Forget(key string)

Forget the value.

func (*Repository) Get

func (r *Repository) Get(key string, target interface{}) error

Get saved value by the key.

func (*Repository) Has

func (r *Repository) Has(key string) bool

Has checks if there is such item.

func (*Repository) Pull

func (r *Repository) Pull(key string, target interface{}) error

Pull saved value by the key.

func (*Repository) Put

func (r *Repository) Put(key string, value interface{}, duration time.Duration)

Put value in cache by key.

func (*Repository) Remember

func (r *Repository) Remember(key string, duration time.Duration, callback func() (interface{}, error), target interface{}) error

Remember returns value if it was saved, or saves the value from the callback.

func (*Repository) RememberForever

func (r *Repository) RememberForever(key string, callback func() (interface{}, error), target interface{}) error

RememberForever returns value if it was saved, or saves the value from the callback for ever.

type ServiceProvider

type ServiceProvider struct{}

ServiceProvider struct.

func (*ServiceProvider) Register

func (p *ServiceProvider) Register(application *larago.Application)

Register service.

type Store

type Store interface {
	// Has checks if there is such item.
	Has(key string) bool

	// Put value in store by key.
	Put(key string, value interface{}, duration time.Duration) error

	// Forever put value in store by key forever.
	Forever(key string, value interface{}) error

	// Get saved value by the key.
	Get(key string, target interface{}) error

	// Forget the value.
	Forget(key string)

	// Clear storage.
	Clear()
}

Store interface.

Jump to

Keyboard shortcuts

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