Documentation
¶
Overview ¶
Package redis provides a Redis-based implementation of the route table.
Index ¶
- type Cmdable
- type RouteTable
- func (r *RouteTable) Del(ctx context.Context, key string) error
- func (r *RouteTable) DelIfSame(ctx context.Context, key, expect string) error
- func (r *RouteTable) Expire(ctx context.Context, key string, expire time.Duration) error
- func (r *RouteTable) GetSet(ctx context.Context, key, val string, expire time.Duration) (string, error)
- func (r *RouteTable) Load(ctx context.Context, key string) (string, error)
- func (r *RouteTable) LoadAndExpire(ctx context.Context, key string, expire time.Duration) (string, error)
- func (r *RouteTable) Set(ctx context.Context, key, val string, expire time.Duration) error
- func (r *RouteTable) SetNx(ctx context.Context, key, val string, expire time.Duration) (bool, string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmdable ¶ added in v0.0.7
type Cmdable interface { Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd Get(ctx context.Context, key string) *redis.StringCmd Del(ctx context.Context, keys ...string) *redis.IntCmd GetSet(ctx context.Context, key string, value interface{}) *redis.StringCmd SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.BoolCmd Expire(ctx context.Context, key string, expiration time.Duration) *redis.BoolCmd }
Cmdable is an interface that represents Redis command execution capability.
type RouteTable ¶ added in v0.0.7
type RouteTable struct {
// contains filtered or unexported fields
}
RouteTable implements the routetable.Data interface using Redis.
func New ¶ added in v0.0.7
func New(client Cmdable) *RouteTable
New creates a new Redis-based route table data store.
func (*RouteTable) Del ¶ added in v0.0.7
func (r *RouteTable) Del(ctx context.Context, key string) error
Del deletes a key from Redis.
func (*RouteTable) DelIfSame ¶ added in v0.0.7
func (r *RouteTable) DelIfSame(ctx context.Context, key, expect string) error
DelIfSame deletes a key only if its current value matches the specified value.
func (*RouteTable) GetSet ¶ added in v0.0.7
func (r *RouteTable) GetSet(ctx context.Context, key, val string, expire time.Duration) (string, error)
GetSet atomically sets a new value and returns the old value.
func (*RouteTable) LoadAndExpire ¶ added in v0.0.7
func (r *RouteTable) LoadAndExpire(ctx context.Context, key string, expire time.Duration) (string, error)
LoadAndExpire loads a value and resets its expiration time.
Click to show internal directories.
Click to hide internal directories.