Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(cfg Config, rep repository.Repository, logger kitlog.Logger) (repository.Repository, error)
New returns a new initialized CachedRepository instance.
Types ¶
type Cache ¶
type Cache interface {
// Type identifies underlying cache store type.
Type() string
// Get retrieves k value from the cache store.
// If not present nil will be returned.
Get(ctx context.Context, ns, key string) ([]byte, error)
// Put stores a value into the cache store.
Put(ctx context.Context, ns, key string, val []byte) error
// Del removes keys values from the cache store.
Del(ctx context.Context, ns string, keys ...string) error
// DelNS removes all keys contained under a given namespace from the cache store.
DelNS(ctx context.Context, ns string) error
// HasKey tells whether k is present in the cache store.
HasKey(ctx context.Context, ns, key string) (bool, error)
// Start starts Cache component.
Start(ctx context.Context) error
// Stop stops Cache component.
Stop(ctx context.Context) error
}
Cache defines cache store interface.
type CachedRepository ¶
type CachedRepository struct {
repository.User
repository.Last
repository.Capabilities
repository.Offline
repository.BlockList
repository.Private
repository.Roster
repository.VCard
repository.Archive
repository.Locker
// contains filtered or unexported fields
}
CachedRepository is cached Repository implementation.
func (*CachedRepository) InTransaction ¶
func (c *CachedRepository) InTransaction(ctx context.Context, f func(ctx context.Context, tx repository.Transaction) error) error
InTransaction generates a repository transaction and completes it after it's being used by f function. In case f returns no error tx transaction will be committed.
type Config ¶
type Config struct {
Type string
Redis rediscache.Config
}
Config contains cached repository configuration.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.