cache

package
Version: v0.0.0-...-1335a43 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2013 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package cache provides a generic interface for manipulating a BitTorrent tracker's fast moving data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, driver Driver)

Register makes a database driver available by the provided name. If Register is called twice with the same name or if driver is nil, it panics.

Types

type Driver

type Driver interface {
	New(*config.DataStore) Pool
}

type Pool

type Pool interface {
	Close() error
	Get() (Tx, error)
}

Pool represents a thread-safe pool of connections to the data store that can be used to obtain transactions.

func Open

func Open(conf *config.DataStore) (Pool, error)

Open creates a pool of data store connections specified by a storage configuration.

type Tx

type Tx interface {
	// Reads
	FindUser(passkey string) (*models.User, bool, error)
	FindTorrent(infohash string) (*models.Torrent, bool, error)
	ClientWhitelisted(peerID string) (bool, error)

	// Writes
	RecordSnatch(u *models.User, t *models.Torrent) error
	MarkActive(t *models.Torrent) error
	AddLeecher(t *models.Torrent, p *models.Peer) error
	AddSeeder(t *models.Torrent, p *models.Peer) error
	RemoveLeecher(t *models.Torrent, p *models.Peer) error
	RemoveSeeder(t *models.Torrent, p *models.Peer) error
	SetLeecher(t *models.Torrent, p *models.Peer) error
	SetSeeder(t *models.Torrent, p *models.Peer) error
	IncrementSlots(u *models.User) error
	DecrementSlots(u *models.User) error
	LeecherFinished(t *models.Torrent, p *models.Peer) error

	// Priming / Testing
	AddTorrent(t *models.Torrent) error
	RemoveTorrent(t *models.Torrent) error
	AddUser(u *models.User) error
	RemoveUser(u *models.User) error
	WhitelistClient(peerID string) error
	UnWhitelistClient(peerID string) error
}

The transmit object is the interface to add, remove and modify data in the cache

Source Files

Directories

Path Synopsis
Package redis implements the storage interface for a BitTorrent tracker.
Package redis implements the storage interface for a BitTorrent tracker.

Jump to

Keyboard shortcuts

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