redis

package
v0.0.0-...-461761a Latest Latest
Warning

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

Go to latest
Published: Aug 3, 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 JSON-formatted strings. Torrents' keys are named "torrent:<infohash>" with an optional prefix. Users' keys are named "user:<passkey>" with an optional prefix.

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() (storage.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) 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 *storage.User) error

func (*Tx) FindTorrent

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

func (*Tx) FindUser

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

func (*Tx) IncrementSlots

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

func (*Tx) MarkActive

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

func (*Tx) NewLeecher

func (tx *Tx) NewLeecher(t *storage.Torrent, p *storage.Peer) error

func (*Tx) NewSeeder

func (tx *Tx) NewSeeder(t *storage.Torrent, p *storage.Peer) error

func (*Tx) RmLeecher

func (tx *Tx) RmLeecher(t *storage.Torrent, p *storage.Peer) error

func (*Tx) RmSeeder

func (tx *Tx) RmSeeder(t *storage.Torrent, p *storage.Peer) error

func (*Tx) Rollback

func (tx *Tx) Rollback() error

func (*Tx) SetLeecher

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

func (*Tx) SetSeeder

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

func (*Tx) Snatch

func (tx *Tx) Snatch(user *storage.User, torrent *storage.Torrent) error

Jump to

Keyboard shortcuts

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