Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNilFiller returned when GetWithFiller called with nil // filler func ErrNilFiller = errors.New("nil filler") )
Functions ¶
This section is empty.
Types ¶
type Bcache ¶
type Bcache struct {
// contains filtered or unexported fields
}
Bcache represents bcache struct
func (*Bcache) Get ¶
Get gets value for the given key.
It returns the value and true if the key exists
func (*Bcache) GetWithFiller ¶
GetWithFiller gets value for the given key and fill the cache if the given key is not exists.
`filler` will be used to fill(Set) the cache when the given key is not exist. Even there are many goroutines which call `GetWithFiller`, the given `Filler` func will only called once for each of the key.
It useful to avoid cache stampede to the underlying database
type Config ¶
type Config struct { // PeerID is unique ID of this bcache // if PeerID = 0, it will be set using mac address PeerID uint64 // ListenAddr is listen addr of this bcache peer. // used to communicate with other peers ListenAddr string // Peers is the address of the known peers. // we don't need to know all of the other peers, // gossip protocol will find the other peers Peers []string // MaxKeys defines max number of keys in this cache MaxKeys int // Logger to be used // leave it nil to use default logger which do nothing Logger Logger // DeletionDelay adds delay before actually delete the key, // it is used to handle temporary network connection issue, // which could prevent data syncing between nodes. // Leave it to 0 make it use default value: 100 seconds. DeletionDelay int }
Config represents bcache configuration
Source Files ¶
Click to show internal directories.
Click to hide internal directories.