memory

package
v0.0.0-...-729a1dc Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigDefault = Conf{
	GCInterval: 10 * time.Second,
}

ConfigDefault is the default config

Functions

func InitMemoryStore

func InitMemoryStore()

Types

type Conf

type Conf struct {
	// Time before deleting expired keys
	//
	// Default is 10 * time.Second
	GCInterval time.Duration
}

Config defines the config for storage.

type PeerStore

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

func NewPeerStore

func NewPeerStore() *PeerStore

type Storage

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

Storage interface that is implemented by storage providers

var STORE *Storage

func New

func New(conf ...Conf) *Storage

New creates a new memory storage

func (*Storage) Close

func (s *Storage) Close() error

Close the memory storage

func (*Storage) DeleteInfohash

func (s *Storage) DeleteInfohash(key bittorrent.InfoHash) error

Delete key by key

func (*Storage) DeletePeer

func (s *Storage) DeletePeer(key bittorrent.InfoHash, peer bittorrent.Peer)

func (*Storage) GetAllInfoHash

func (s *Storage) GetAllInfoHash() []bittorrent.InfoHash

func (*Storage) GetAllPeers

func (s *Storage) GetAllPeers(key bittorrent.InfoHash, ignore *bittorrent.Peer) []bittorrent.Peer

func (*Storage) GetPeers

func (*Storage) Reset

func (s *Storage) Reset() error

Reset all keys

func (*Storage) ResetPeer

func (s *Storage) ResetPeer(key bittorrent.InfoHash) error

Reset all peer

func (*Storage) SetPeer

SetPeer key with value SetPeer key with value

Jump to

Keyboard shortcuts

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