Documentation ¶
Index ¶
- Variables
- func New(ctx context.Context, conf CacheConfig) (domain.Cacher, error)
- func WithHeartbeatCleanup(ch chan<- any) options
- func WithHeartbeatPair(ch chan<- any) options
- func WithHeartbeatToken(ch chan<- any) options
- type CacheConfig
- type Mem
- func (m *Mem) Add(_ context.Context, queue uint64, album uint64) error
- func (m *Mem) Allow(_ context.Context, ip uint64) (bool, error)
- func (m *Mem) Del(_ context.Context, token uint64) error
- func (m *Mem) Get(_ context.Context, token uint64) (uint64, uint64, error)
- func (m *Mem) Health(_ context.Context) (bool, error)
- func (m *Mem) Monitor(ctx context.Context)
- func (m *Mem) PAdd(_ context.Context, pqueue uint64, album uint64, expires time.Time) error
- func (m *Mem) PPoll(_ context.Context, pqueue uint64) (uint64, time.Time, error)
- func (m *Mem) PSize(_ context.Context, pqueue uint64) (int, error)
- func (m *Mem) Poll(_ context.Context, queue uint64) (uint64, error)
- func (m *Mem) Pop(_ context.Context, album uint64) (uint64, uint64, error)
- func (m *Mem) Push(_ context.Context, album uint64, pairs [][2]uint64) error
- func (m *Mem) Reset() error
- func (m *Mem) Set(_ context.Context, token uint64, album uint64, image uint64) error
- func (m *Mem) Size(_ context.Context, queue uint64) (int, error)
- type MemConfig
- type Redis
- func (r *Redis) Add(ctx context.Context, queue uint64, album uint64) error
- func (r *Redis) Allow(ctx context.Context, ip uint64) (bool, error)
- func (r *Redis) Close(_ context.Context) error
- func (r *Redis) Del(ctx context.Context, token uint64) error
- func (r *Redis) Get(ctx context.Context, token uint64) (uint64, uint64, error)
- func (r *Redis) Health(ctx context.Context) (bool, error)
- func (r *Redis) PAdd(ctx context.Context, pqueue uint64, album uint64, expires time.Time) error
- func (r *Redis) PPoll(ctx context.Context, pqueue uint64) (uint64, time.Time, error)
- func (r *Redis) PSize(ctx context.Context, pqueue uint64) (int, error)
- func (r *Redis) Poll(ctx context.Context, queue uint64) (uint64, error)
- func (r *Redis) Pop(ctx context.Context, album uint64) (uint64, uint64, error)
- func (r *Redis) Push(ctx context.Context, album uint64, pairs [][2]uint64) error
- func (r *Redis) Reset() error
- func (r *Redis) Set(ctx context.Context, token uint64, album uint64, image uint64) error
- func (r *Redis) Size(ctx context.Context, queue uint64) (int, error)
- type RedisConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultMemConfig = MemConfig{ CleanupInterval: 0, LimiterRequestsPerSecond: 30000, LimiterBurst: 300, TimeToLive: 0, } DefaultRedisConfig = RedisConfig{ Host: "localhost", Port: "6379", RetryTimes: 4, RetryPause: 5 * time.Second, Timeout: 30 * time.Second, LimiterRequestsPerSecond: 1, LimiterBurst: 1, TimeToLive: 3 * time.Second, TxRetries: 1, } )
Functions ¶
func WithHeartbeatCleanup ¶
func WithHeartbeatCleanup(ch chan<- any) options
func WithHeartbeatPair ¶
func WithHeartbeatPair(ch chan<- any) options
func WithHeartbeatToken ¶
func WithHeartbeatToken(ch chan<- any) options
Types ¶
type CacheConfig ¶
type CacheConfig struct { Cache string `mapstructure:"APP_CACHE" validate:"required"` Mem MemConfig `mapstructure:",squash"` Redis RedisConfig `mapstructure:",squash"` }
type Mem ¶
type Mem struct {
// contains filtered or unexported fields
}
type MemConfig ¶
type MemConfig struct { CleanupInterval time.Duration `mapstructure:"CACHE_MEM_CLEANUP_INTERVAL" validate:"required"` LimiterRequestsPerSecond float64 `mapstructure:"MIDDLEWARE_LIMITER_REQUESTS_PER_SECOND" validate:"required"` LimiterBurst int `mapstructure:"MIDDLEWARE_LIMITER_BURST" validate:"required"` TimeToLive time.Duration `mapstructure:"CACHE_REDIS_TIME_TO_LIVE" validate:"required"` }
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
type RedisConfig ¶
type RedisConfig struct { Host string `mapstructure:"CACHE_REDIS_HOST" validate:"required"` Port string `mapstructure:"CACHE_REDIS_PORT" validate:"required"` RetryTimes int `mapstructure:"CACHE_REDIS_RETRY_TIMES" validate:"required"` RetryPause time.Duration `mapstructure:"CACHE_REDIS_RETRY_PAUSE" validate:"required"` Timeout time.Duration `mapstructure:"CACHE_REDIS_TIMEOUT" validate:"required"` LimiterRequestsPerSecond int `mapstructure:"MIDDLEWARE_LIMITER_REQUESTS_PER_SECOND" validate:"required"` LimiterBurst int64 `mapstructure:"MIDDLEWARE_LIMITER_BURST" validate:"required"` TimeToLive time.Duration `mapstructure:"CACHE_REDIS_TIME_TO_LIVE" validate:"required"` TxRetries int `mapstructure:"CACHE_REDIS_TX_RETRIES" validate:"required"` }
Click to show internal directories.
Click to hide internal directories.