mirror of
https://github.com/sot-tech/mochi.git
synced 2026-06-06 13:11:55 -07:00
docs updated
This commit is contained in:
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
// which can be found in the LICENSE file.
|
// which can be found in the LICENSE file.
|
||||||
|
|
||||||
// Package storage provides a generic interface for manipulating a
|
// Package storage provides a generic interface for manipulating a
|
||||||
// BitTorrent tracker's cache.
|
// BitTorrent tracker's fast moving data.
|
||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
Vendored
+6
-13
@@ -5,9 +5,12 @@
|
|||||||
// Package redis implements the storage interface for a BitTorrent tracker.
|
// Package redis implements the storage interface for a BitTorrent tracker.
|
||||||
//
|
//
|
||||||
// The client whitelist is represented as a set with the key name "whitelist"
|
// The client whitelist is represented as a set with the key name "whitelist"
|
||||||
// with an optional prefix. Torrents and users are JSON-formatted strings.
|
// with an optional prefix. Torrents and users are represented as hashes.
|
||||||
// Torrents' keys are named "torrent:<infohash>" with an optional prefix.
|
// Torrents' keys are named "torrent:<infohash>" with an optional prefix.
|
||||||
// Users' keys are named "user:<passkey>" 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.
|
||||||
package redis
|
package redis
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -38,17 +41,7 @@ func (d *driver) New(conf *config.Cache) cache.Pool {
|
|||||||
|
|
||||||
func makeDialFunc(conf *config.Cache) func() (redis.Conn, error) {
|
func makeDialFunc(conf *config.Cache) func() (redis.Conn, error) {
|
||||||
return func() (conn redis.Conn, err error) {
|
return func() (conn redis.Conn, err error) {
|
||||||
if conf.ConnTimeout != nil {
|
conn, err = redis.Dial(conf.Network, conf.Addr)
|
||||||
conn, err = redis.DialTimeout(
|
|
||||||
conf.Network,
|
|
||||||
conf.Addr,
|
|
||||||
conf.ConnTimeout.Duration, // Connect Timeout
|
|
||||||
conf.ConnTimeout.Duration, // Read Timeout
|
|
||||||
conf.ConnTimeout.Duration, // Write Timeout
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
conn, err = redis.Dial(conf.Network, conf.Addr)
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ type Cache struct {
|
|||||||
|
|
||||||
MaxIdleConn int `json:"max_idle_conn"`
|
MaxIdleConn int `json:"max_idle_conn"`
|
||||||
IdleTimeout *Duration `json:"idle_timeout"`
|
IdleTimeout *Duration `json:"idle_timeout"`
|
||||||
ConnTimeout *Duration `json:"conn_timeout"`
|
|
||||||
TxRetries int `json:"tx_retries"`
|
TxRetries int `json:"tx_retries"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user