Documentation ¶
Overview ¶
The very core database/cache data operations package.
Index ¶
- func DeleteOne(cache Cacher, key string) bool
- func DumpAll() string
- func FanInChannels(l common.Logger, channels ...chan interface{}) <-chan interface{}
- func GetAll[T any](cache Cacher, model T) (map[string]T, int64)
- func GetGravatarURL(user models.User, channel chan interface{}, wg *sync.WaitGroup) string
- func GetOne[T any](cache Cacher, key string, model T) (T, bool)
- func LoadAll() string
- func Lock()
- func RLock()
- func RUnlock()
- func ReleaseLock()
- func Router() chi.Router
- func RunMigrations() string
- func SetOne[T any](cache Cacher, key string, model T) bool
- func Unlock()
- type Cacher
- type Database
- type DefaultCache
- type GenericMap
- type Repositories
- type SignalCache
- type SimpleCache
- func (c *SimpleCache) Delete(key string) bool
- func (c *SimpleCache) GetName() string
- func (c *SimpleCache) Load(key string) (interface{}, bool)
- func (c *SimpleCache) LoadOrStore(key string, rawV interface{}) (interface{}, bool)
- func (c *SimpleCache) Range() (*GenericMap, int64)
- func (c *SimpleCache) Store(key string, rawV interface{}) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteOne ¶
DeleteOne deletes an item from such cache via the requested key value. Fails if the database state is locked.
func FanInChannels ¶ added in v0.44.19
FanInChannels is a helper function that collects results from multiple workers.
func GetAll ¶
GetAll function does a fetch-all operation on the given cache instance. After the data retrieval, all items are to be asserted their corresponding types and to be loaded into a map[string]T map, where T is a generic type. This map and number of processed items are returned.
func GetGravatarURL ¶
GetGravatarURL function returns the avatar image location/URL, or it defaults to a app logo.
func GetOne ¶
GetOne fetches just one very item from the given cache instance. As long as the function is generic, the type is asserted automatically, so the type passing is required. Returns the requested item and the its retrieval result as boolean.
func ReleaseLock ¶ added in v0.44.19
func ReleaseLock()
ReleaseLock is a special function evoked when the lock needs to be released before the backend shutdown not to defer its exit, but to keep the database stack in the read-only state.
func RunMigrations ¶
func RunMigrations() string
RunMigrations is a wrapper function for the migration registration and execution.
func SetOne ¶
SetOne writes the input value of some type to the corresponding cache storing the very same item type (TODO ensure this). Fails if the database state is locked or uninitialized. Please note that this very function has to have another sync mechanism implemented, as the combined read+write operation is not considered a thread safe.
Types ¶
type Cacher ¶ added in v0.44.19
type Cacher interface { // Load takes a key string and fetches its value from the implementing cache store. // Returns true if the item has been found, otherwise writes false. Load(key string) (interface{}, bool) // Store takes a key-value pair and stores the value with the associated key into the implementing cache store. // Simple overwrite. Store(key string, value interface{}) bool // Delete takes a key string and deletes its record in the implementing cache store. Delete(key string) bool // Range loop over all the implementing cache keys and retrieves all the associated values as interface{}. // Returns the pointer to a GenericMap with all keys and their associated values, and the item count. Range() (*GenericMap, int64) // GetName returns the implemented cache's name. GetName() string }
type DefaultCache ¶ added in v0.44.19
type DefaultCache struct { // Name of the cache. Name string // contains filtered or unexported fields }
func NewDefaultCache ¶ added in v0.44.19
func NewDefaultCache(name string) *DefaultCache
func (*DefaultCache) Delete ¶ added in v0.44.19
func (c *DefaultCache) Delete(key string) bool
func (*DefaultCache) GetName ¶ added in v0.44.19
func (c *DefaultCache) GetName() string
func (*DefaultCache) Load ¶ added in v0.44.19
func (c *DefaultCache) Load(key string) (interface{}, bool)
func (*DefaultCache) Range ¶ added in v0.44.19
func (c *DefaultCache) Range() (*GenericMap, int64)
func (*DefaultCache) Store ¶ added in v0.44.19
func (c *DefaultCache) Store(key string, rawV interface{}) bool
type GenericMap ¶ added in v0.44.19
type GenericMap map[string]interface{}
type Repositories ¶ added in v0.44.22
type Repositories struct { PollRepository models.PollRepositoryInterface PostRepository models.PostRepositoryInterface UserRepository models.UserRepositoryInterface }
var Storage *Repositories
type SignalCache ¶ added in v0.44.19
type SignalCache struct { // Name of the cache. Name string // contains filtered or unexported fields }
func NewSignalCache ¶ added in v0.44.19
func NewSignalCache(name string) *SignalCache
func (*SignalCache) Delete ¶ added in v0.44.19
func (c *SignalCache) Delete(key string) bool
func (*SignalCache) GetName ¶ added in v0.44.19
func (c *SignalCache) GetName() string
func (*SignalCache) Load ¶ added in v0.44.19
func (c *SignalCache) Load(key string) (interface{}, bool)
func (*SignalCache) Range ¶ added in v0.44.19
func (c *SignalCache) Range() (*GenericMap, int64)
func (*SignalCache) Store ¶ added in v0.44.19
func (c *SignalCache) Store(key string, rawV interface{}) bool
type SimpleCache ¶ added in v0.44.19
type SimpleCache struct { // Name of the cache. Name string // contains filtered or unexported fields }
func NewSimpleCache ¶ added in v0.44.19
func NewSimpleCache(name string) *SimpleCache
func (*SimpleCache) Delete ¶ added in v0.44.19
func (c *SimpleCache) Delete(key string) bool
func (*SimpleCache) GetName ¶ added in v0.44.19
func (c *SimpleCache) GetName() string
func (*SimpleCache) Load ¶ added in v0.44.19
func (c *SimpleCache) Load(key string) (interface{}, bool)
func (*SimpleCache) LoadOrStore ¶ added in v0.44.23
func (c *SimpleCache) LoadOrStore(key string, rawV interface{}) (interface{}, bool)
func (*SimpleCache) Range ¶ added in v0.44.19
func (c *SimpleCache) Range() (*GenericMap, int64)
func (*SimpleCache) Store ¶ added in v0.44.19
func (c *SimpleCache) Store(key string, rawV interface{}) bool