redis

package
v0.0.0-...-a2527aa Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2013 License: BSD-2-Clause Imports: 7 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

func (*Pool) Close

func (p *Pool) Close() error

func (*Pool) Get

func (p *Pool) Get() (cache.Tx, error)

type Tx

type Tx struct {
	redis.Conn
	// contains filtered or unexported fields
}

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

func (*Tx) AddLeecher

func (tx *Tx) AddLeecher(t *models.Torrent, p *models.Peer) error

func (*Tx) AddSeeder

func (tx *Tx) AddSeeder(t *models.Torrent, p *models.Peer) error

func (*Tx) ClientWhitelisted

func (tx *Tx) ClientWhitelisted(peerID string) (exists bool, err error)

func (*Tx) Commit

func (tx *Tx) Commit() error

func (*Tx) DecrementSlots

func (tx *Tx) DecrementSlots(u *models.User) error

func (*Tx) FindTorrent

func (tx *Tx) FindTorrent(infohash string) (*models.Torrent, bool, error)

func (*Tx) FindUser

func (tx *Tx) FindUser(passkey string) (*models.User, bool, error)

func (*Tx) IncrementSlots

func (tx *Tx) IncrementSlots(u *models.User) error

func (*Tx) MarkActive

func (tx *Tx) MarkActive(t *models.Torrent) error

func (*Tx) RecordSnatch

func (tx *Tx) RecordSnatch(user *models.User, torrent *models.Torrent) error

func (*Tx) RemoveLeecher

func (tx *Tx) RemoveLeecher(t *models.Torrent, p *models.Peer) error

func (*Tx) RemoveSeeder

func (tx *Tx) RemoveSeeder(t *models.Torrent, p *models.Peer) error

func (*Tx) Rollback

func (tx *Tx) Rollback() error

func (*Tx) SetLeecher

func (tx *Tx) SetLeecher(t *models.Torrent, p *models.Peer) error

func (*Tx) SetSeeder

func (tx *Tx) SetSeeder(t *models.Torrent, p *models.Peer) error

Jump to

Keyboard shortcuts

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