Documentation
¶
Overview ¶
Package redis implements the storage interface for a BitTorrent tracker.
The client whitelist is represented as a set with the key name "whitelist" with an optional prefix. Torrents and users are represented as hashes. Torrents' keys are named "torrent:<infohash>" with an optional prefix. Users' keys are named "user:<passkey>" with an optional prefix. The seeders and leechers attributes of torrent hashes are strings that represent the key for those hashes within redis. This is done because redis cannot nest their hash data type.
Index ¶
- type Pool
- type Tx
- func (tx *Tx) AddLeecher(t *models.Torrent, p *models.Peer) error
- func (tx *Tx) AddSeeder(t *models.Torrent, p *models.Peer) error
- func (tx *Tx) ClientWhitelisted(peerID string) (exists bool, err error)
- func (tx *Tx) Commit() error
- func (tx *Tx) DecrementSlots(u *models.User) error
- func (tx *Tx) FindTorrent(infohash string) (*models.Torrent, bool, error)
- func (tx *Tx) FindUser(passkey string) (*models.User, bool, error)
- func (tx *Tx) IncrementSlots(u *models.User) error
- func (tx *Tx) MarkActive(t *models.Torrent) error
- func (tx *Tx) RecordSnatch(user *models.User, torrent *models.Torrent) error
- func (tx *Tx) RemoveLeecher(t *models.Torrent, p *models.Peer) error
- func (tx *Tx) RemoveSeeder(t *models.Torrent, p *models.Peer) error
- func (tx *Tx) Rollback() error
- func (tx *Tx) SetLeecher(t *models.Torrent, p *models.Peer) error
- func (tx *Tx) SetSeeder(t *models.Torrent, p *models.Peer) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tx ¶
Tx represents a transaction for Redis with one gotcha: all reads must be done prior to any writes. Writes will check if the MULTI command has been sent to redis and will send it if it hasn't.
Internally a transaction looks like: WATCH keyA GET keyA WATCH keyB GET keyB MULTI SET keyA SET keyB EXEC