bcache

package
v1.34.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 28 Imported by: 8

Documentation

Index

Constants

View Source
const (
	DefaultTimeOut    = 1 * time.Second
	ConnectExpireTime = 20
)
View Source
const (
	PathListSeparator    = ";"
	CacheConfSeparator   = ":"
	SpaceCheckInterval   = 60 * time.Second
	TmpFileCheckInterval = 20 * 60 * time.Second
	FilePerm             = 0o644
	Basedir              = "blocks"
)
View Source
const (
	OpBlockCachePut uint8 = 0xB1
	OpBlockCacheGet uint8 = 0xB2
	OpBlockCacheDel uint8 = 0xB3
)
View Source
const (
	UnixSocketPath = "/var/run/cubefscache/bcache.socket"

	// config
	CacheDir      = "cacheDir"
	CacheLimit    = "cacheLimit"
	CacheFree     = "cacheFree"
	BlockSize     = "blockSize"
	MaxFileSize   = 128 << 30
	MaxBlockSize  = 128 << 20
	BigExtentSize = 32 << 20
)
View Source
const (
	CacheMagic uint8 = 0xFF
)
View Source
const (
	PacketHeaderSize = 11
)

Variables

View Source
var Buffers *buf.BufferPool

Functions

func AccessTime

func AccessTime(info os.FileInfo) int64

func NewServer

func NewServer() *bcacheStore

Types

type BcacheClient

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

func NewBcacheClient

func NewBcacheClient() *BcacheClient

func (*BcacheClient) Evict

func (c *BcacheClient) Evict(key string) error

func (*BcacheClient) Get

func (c *BcacheClient) Get(key string, buf []byte, offset uint64, size uint32) (int, error)

func (*BcacheClient) Put

func (c *BcacheClient) Put(key string, buf []byte) error

type BcacheManager

type BcacheManager interface {
	// contains filtered or unexported methods
}

type BlockCachePacket

type BlockCachePacket struct {
	Magic      uint8
	Opcode     uint8
	ResultCode uint8 // 3
	CRC        uint32
	Size       uint32 // Data's size ; header size: 3 + 8 = 11
	Data       []byte
	StartT     int64
}

func NewBlockCachePacket

func NewBlockCachePacket() *BlockCachePacket

func (*BlockCachePacket) GetOpMsg

func (p *BlockCachePacket) GetOpMsg() (m string)

func (*BlockCachePacket) GetResultMsg

func (p *BlockCachePacket) GetResultMsg() (m string)

func (*BlockCachePacket) MarshalData

func (p *BlockCachePacket) MarshalData(v interface{}) error

func (*BlockCachePacket) MarshalHeader

func (p *BlockCachePacket) MarshalHeader(out []byte)

func (*BlockCachePacket) PacketErrorWithBody

func (p *BlockCachePacket) PacketErrorWithBody(code uint8, reply []byte)

func (*BlockCachePacket) PacketOkReplay

func (p *BlockCachePacket) PacketOkReplay()

func (*BlockCachePacket) PacketOkWithBody

func (p *BlockCachePacket) PacketOkWithBody(reply []byte)

func (*BlockCachePacket) ReadFromConn

func (p *BlockCachePacket) ReadFromConn(c net.Conn, timeoutSec int) (err error)

func (*BlockCachePacket) String

func (p *BlockCachePacket) String() string

func (*BlockCachePacket) UnMarshalHeader

func (p *BlockCachePacket) UnMarshalHeader(in []byte) error

func (*BlockCachePacket) UnmarshalData

func (p *BlockCachePacket) UnmarshalData(v interface{}) error

func (*BlockCachePacket) WriteToConn

func (p *BlockCachePacket) WriteToConn(c net.Conn) (err error)

type ConnObject

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

type ConnPool

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

func NewConnPool

func NewConnPool(target string, mincap, maxcap int, expire int64) *ConnPool

func (*ConnPool) Get

func (connPool *ConnPool) Get() (c *net.Conn, err error)

func (*ConnPool) NewConnect

func (connPool *ConnPool) NewConnect(target string) (*net.Conn, error)

func (*ConnPool) Put

func (connPool *ConnPool) Put(c *net.Conn)

type DelCacheRequest

type DelCacheRequest struct {
	CacheKey string `json:"key"`
}

type DiskStore

type DiskStore struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewDiskStore

func NewDiskStore(dir string, cacheSize int64, config *bcacheConfig) *DiskStore

type GetCacheDataResponse

type GetCacheDataResponse struct {
	Data []byte `json:"data"`
}

type GetCachePathResponse

type GetCachePathResponse struct {
	CachePath string `json:"path"`
}

type GetCacheRequest

type GetCacheRequest struct {
	CacheKey string `json:"key"`
	Offset   uint64 `json:"offset"`
	Size     uint32 `json:"size"`
}

type PutCacheRequest

type PutCacheRequest struct {
	CacheKey string `json:"key"`
	Data     []byte `json:"data"`
}

type ReadCloser

type ReadCloser interface {
	io.Reader
	io.ReaderAt
	io.Closer
}

Jump to

Keyboard shortcuts

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