Documentation
¶
Index ¶
- Variables
- type Cache
- type CommandCacheClear
- type DatabaseItem
- type DatabaseStore
- func (s *DatabaseStore) Clear()
- func (s *DatabaseStore) Forever(key string, value interface{}) error
- func (s *DatabaseStore) Forget(key string)
- func (s *DatabaseStore) Get(key string, target interface{}) error
- func (s *DatabaseStore) Has(key string) bool
- func (s *DatabaseStore) Put(key string, value interface{}, duration time.Duration) error
- type InMemoryStore
- func (s *InMemoryStore) Clear()
- func (s *InMemoryStore) Forever(key string, value interface{}) error
- func (s *InMemoryStore) Forget(key string)
- func (s *InMemoryStore) Get(key string, target interface{}) error
- func (s *InMemoryStore) Has(key string) bool
- func (s *InMemoryStore) Put(key string, value interface{}, duration time.Duration) error
- type Repository
- func (r *Repository) Clear()
- func (r *Repository) Forever(key string, value interface{})
- func (r *Repository) Forget(key string)
- func (r *Repository) Get(key string, target interface{}) error
- func (r *Repository) Has(key string) bool
- func (r *Repository) Pull(key string, target interface{}) error
- func (r *Repository) Put(key string, value interface{}, duration time.Duration)
- func (r *Repository) Remember(key string, duration time.Duration, callback func() (interface{}, error), ...) error
- func (r *Repository) RememberForever(key string, callback func() (interface{}, error), target interface{}) error
- type ServiceProvider
- type Store
Constants ¶
This section is empty.
Variables ¶
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") )
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
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.
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.
type DatabaseStore ¶
DatabaseStore .
func NewDatabaseStore ¶
func NewDatabaseStore(table string) *DatabaseStore
NewDatabaseStore constructor.
func (*DatabaseStore) Forever ¶
func (s *DatabaseStore) Forever(key string, value interface{}) error
Forever put value in store by key forever.
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.
type InMemoryStore ¶
type InMemoryStore struct {
// contains filtered or unexported fields
}
InMemoryStore .
func (*InMemoryStore) Forever ¶
func (s *InMemoryStore) Forever(key string, value interface{}) error
Forever put value in store by key forever.
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.
type Repository ¶
Repository .
func (*Repository) Forever ¶
func (r *Repository) Forever(key string, value interface{})
Forever remembers the value for ever.
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.