Documentation
¶
Index ¶
- Constants
- type Cache
- type CacheItem
- type CacheSimple
- type LogLevel
- type Logger
- type LoggerAware
- type LoggerNull
- func (l *LoggerNull) Alert(message string, context []any) error
- func (l *LoggerNull) Critical(message string, context []any) error
- func (l *LoggerNull) Debug(message string, context []any) error
- func (l *LoggerNull) Emergency(message string, context []any) error
- func (l *LoggerNull) Error(message string, context []any) error
- func (l *LoggerNull) Info(message string, context []any) error
- func (l *LoggerNull) Log(level LogLevel, message string, context []any) error
- func (l *LoggerNull) Notice(message string, context []any) error
- func (l *LoggerNull) Warning(message string, context []any) error
Constants ¶
const KeepTTL = -1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
// GetItem Returns a CacheItem representing the specified key.
GetItem(key string) CacheItem
// GetItems Returns a list of cache items.
GetItems(keys ...string) []CacheItem
// HasItem Confirms if the cache contains specified cache item.
HasItem(key string) bool
// Clear Deletes all items in the pool
Clear() error
// DeleteItem Removes the item from the pool.
DeleteItem(key string) error
// DeleteItems Removes multiple items from the pool.
DeleteItems(keys ...string) error
// Save Persists a cache item immediately.
Save(item CacheItem) error
// SaveDeferred Sets a cache item to be persisted later.
SaveDeferred(item CacheItem) error
// Commit Persists any deferred cache items.
Commit() error
}
type CacheItem ¶
type CacheItem interface {
// GetKey Returns the key for the current cache item.
GetKey() string
// Get Retrieves the value of the item from the cache.
Get() any
// IsHit Confirms if the cache item lookup resulted in a cache hit.
IsHit() bool
// Set Sets the value represented by this cache item
Set(value any, ttl time.Duration) (CacheItem, error)
// ExpiresAt Sets the absolute expiration time for this cache item.
ExpiresAt(expiration time.Time) (CacheItem, error)
// ExpiresAfter Sets the relative expiration time for this cache item.
ExpiresAfter(t time.Duration)
}
type CacheSimple ¶
type CacheSimple interface {
// Get Returns a value from the cache.
Get(key string, defaultValue any) any
// GetMultiply Returns a list of cache items.
GetMultiply(keys []string, defaultValue any) []any
// Has Determines whether an item is present in the cache.
Has(key string) bool
// Clear Deletes all cache's keys.
Clear() error
// Delete Remove an item from the cache.
Delete(key string) error
// DeleteMultiply Removes multiple items in a single operation.
DeleteMultiply(keys ...string) error
// Set Persists a cache item.
Set(key string, item any, ttl time.Duration) error
// SetMultiply Persists a cache items.
SetMultiply(values map[string]any, ttl time.Duration) error
}
type Logger ¶
type Logger interface {
// Emergency System is unusable
Emergency(message string, context []any) error
// Alert Action must be taken immediately.
Alert(message string, context []any) error
// Critical Critical conditions.
Critical(message string, context []any) error
// Error Runtime errors that do not require immediate action but should typically
Error(message string, context []any) error
// Warning Exceptional occurrences that are not errors.
Warning(message string, context []any) error
// Notice Normal but significant events.
Notice(message string, context []any) error
// Info Interesting events
Info(message string, context []any) error
// Debug Detailed debug information.
Debug(message string, context []any) error
// Log Logs with an arbitrary level.
Log(level LogLevel, message string, context []any) error
}
type LoggerAware ¶
type LoggerAware interface {
SetLogger(logger Logger)
}
type LoggerNull ¶
type LoggerNull struct {
}
func (*LoggerNull) Alert ¶
func (l *LoggerNull) Alert(message string, context []any) error
Alert Action must be taken immediately.
func (*LoggerNull) Critical ¶
func (l *LoggerNull) Critical(message string, context []any) error
Critical Critical conditions.
func (*LoggerNull) Debug ¶
func (l *LoggerNull) Debug(message string, context []any) error
Debug Detailed debug information.
func (*LoggerNull) Emergency ¶
func (l *LoggerNull) Emergency(message string, context []any) error
Emergency System is unusable
func (*LoggerNull) Error ¶
func (l *LoggerNull) Error(message string, context []any) error
Error Runtime errors that do not require immediate action but should typically
func (*LoggerNull) Info ¶
func (l *LoggerNull) Info(message string, context []any) error
Info Interesting events
func (*LoggerNull) Log ¶
func (l *LoggerNull) Log(level LogLevel, message string, context []any) error
Log Logs with an arbitrary level.