storage

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RedisStorage

type RedisStorage struct {
	// contains filtered or unexported fields
}

func NewRedisStorage

func NewRedisStorage(addr, password string, db int) *RedisStorage

func (*RedisStorage) GetAll

func (s *RedisStorage) GetAll(ctx context.Context) ([]*model.Proxy, error)

func (*RedisStorage) GetRandom

func (s *RedisStorage) GetRandom(ctx context.Context) (*model.Proxy, error)

func (*RedisStorage) GetRedisClient

func (s *RedisStorage) GetRedisClient() *redis.Client

在 RedisStorage 结构体中添加获取客户端的方法

func (*RedisStorage) Remove

func (s *RedisStorage) Remove(ctx context.Context, key string) error

func (*RedisStorage) Save

func (s *RedisStorage) Save(ctx context.Context, proxy *model.Proxy) error

func (*RedisStorage) UpdateScore

func (s *RedisStorage) UpdateScore(ctx context.Context, key string, score int) error

type Storage

type Storage interface {
	Save(context.Context, *model.Proxy) error
	GetAll(context.Context) ([]*model.Proxy, error)
	GetRandom(context.Context) (*model.Proxy, error)
	Remove(context.Context, string) error
	UpdateScore(context.Context, string, int) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL