Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type KeyValue ¶
type KeyValue struct { ID string `gorm:"primaryKey,type:varchar(64)"` Value float64 `gorm:"type:decimal(40,15);"` TTL int64 `gorm:"default:0"` }
KeyValue represent key-value storage in ORM
type PostgresStorage ¶
type PostgresStorage struct {
// contains filtered or unexported fields
}
PostgresStorage pgsql instance
func (*PostgresStorage) Cron ¶
func (store *PostgresStorage) Cron() error
func (*PostgresStorage) Get ¶
func (store *PostgresStorage) Get(key string) (value float64, err error)
type RedisStorage ¶
type RedisStorage struct {
// contains filtered or unexported fields
}
RedisStorage redis client
func (*RedisStorage) Cron ¶
func (store *RedisStorage) Cron() error
type StorageInterface ¶
type StorageInterface interface { // Cron method for execute storage-specific cron-jobs, e.g. cleanup ttl Cron() error // Get return record from storage, or error Get(key string) (float64, error) // SetNX create record if not exists SetNX(key string, value float64, ttl time.Duration) error // Incr atomic increment or decrement Incr(key string, value float64) (float64, error) //float64 precision is enough for votes }
func CreatePostgres ¶
func CreatePostgres(config config.Config) (storage StorageInterface, err error)
CreatePostgres create new instance of PostgresStorage
func CreateRedis ¶
func CreateRedis(config config.Config) (storage StorageInterface, err error)
CreateRedis create instance of RedisStorage
Click to show internal directories.
Click to hide internal directories.