Documentation ¶
Index ¶
- type CacheMiddleware
- type Internal
- func (c *Internal) GetPageByID(id snowflake.ID) (*objects.Page, error)
- func (c *Internal) GetUserByID(id snowflake.ID) (*objects.User, error)
- func (c *Internal) GetUserByToken(token string) (*objects.User, bool)
- func (c *Internal) SetDatabase(db database.Middleware)
- func (c *Internal) SetPageByID(id snowflake.ID, page *objects.Page) error
- func (c *Internal) SetUserByID(id snowflake.ID, user *objects.User) error
- func (c *Internal) SetUserByToken(token string, user *objects.User) error
- type Redis
- func (c *Redis) GetPageByID(id snowflake.ID) (*objects.Page, error)
- func (c *Redis) GetUserByID(id snowflake.ID) (*objects.User, error)
- func (c *Redis) GetUserByToken(token string) (*objects.User, bool)
- func (c *Redis) SetDatabase(db database.Middleware)
- func (c *Redis) SetPageByID(id snowflake.ID, page *objects.Page) error
- func (c *Redis) SetUserByID(id snowflake.ID, user *objects.User) error
- func (c *Redis) SetUserByToken(token string, user *objects.User) error
- type RedisConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheMiddleware ¶
type CacheMiddleware interface { // SetDatabase sets the passed database module // as cache storage fallback. SetDatabase(db database.Middleware) // GetUserByID returns a User object by ID GetUserByID(id snowflake.ID) (*objects.User, error) // SetUserByID sets a User object to the passed ID SetUserByID(id snowflake.ID, user *objects.User) error // GetUserByToken returns a User object by token string GetUserByToken(token string) (*objects.User, bool) // SetUserByToken sets a User object to the passed // token string SetUserByToken(token string, user *objects.User) error // GetPageByID returns a Page object by ID GetPageByID(id snowflake.ID) (*objects.Page, error) // SetPageByID sets a Page object to the passed ID SetPageByID(id snowflake.ID, page *objects.Page) error }
CacheMiddleware describes a caching module providing functionality to store and fetch data to/from a cache storage. This module will be initialized with SetDatabase. The set database must be used to fetch data from when a value is not found in cache. This value must then be saved in the cache storage.
type Internal ¶
type Internal struct {
// contains filtered or unexported fields
}
Internal provides a caching module which uses a timedmap.TimedMap instance to store and manage cache values.
func (*Internal) GetPageByID ¶
func (*Internal) GetUserByID ¶
func (*Internal) GetUserByToken ¶
func (*Internal) SetDatabase ¶
func (c *Internal) SetDatabase(db database.Middleware)
func (*Internal) SetPageByID ¶
func (*Internal) SetUserByID ¶
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
Redis provides a caching module which uses Redis to store and manage cache values.
func NewRedis ¶
func NewRedis(cfg *RedisConfig) *Redis
NewRedis creates a new instance of Redis with the given RedisConfig instance cfg.
func (*Redis) SetDatabase ¶
func (c *Redis) SetDatabase(db database.Middleware)
Click to show internal directories.
Click to hide internal directories.