Versions in this module Expand all Collapse all v2 v2.0.1 Apr 22, 2026 v2.0.0 Apr 22, 2026 Changes in this version + const EOFHint + var ErrBadHeader = errors.New("bad header") + var ErrCacheFull = errors.New("cache full") + var ErrInvalidDataFileName = errors.New("invalid datafile name") + var ErrInvalidDataFileNameSuffix = errors.New("invalid datafile name suffix") + var ErrInvalidStreamSize = errors.New("invalid stream size") + var ErrNoData = errors.New("no data") + var ErrTooLargeData = errors.New("too large data") + var ErrTooSmallReadBuf = errors.New("too small read buffer") + var ErrUnexpectedReadSize = errors.New("unexpected read size") + func GetErrorContext(err error) map[string]interface + func IsRetryable(err error) bool + func Metrics() []prometheus.Collector + func ResetMetrics() + type BufFunc func() []byte + type CacheError struct + Caller string + Details string + Err error + File string + Operation Operation + Path string + func NewCacheError(op Operation, err error, details string) *CacheError + func WrapCloseError(err error, path string, fdType string) *CacheError + func WrapFileOperationError(op Operation, err error, path, file string) *CacheError + func WrapGetError(err error, path string, file string) *CacheError + func WrapLockError(err error, path string, pid int) *CacheError + func WrapOpenError(err error, path string) *CacheError + func WrapPosError(err error, path string, seek int64) *CacheError + func WrapPutError(err error, path string, dataSize int) *CacheError + func WrapRotateError(err error, path string, oldFile, newFile string) *CacheError + func (e *CacheError) Error() string + func (e *CacheError) Unwrap() error + func (e *CacheError) WithDetails(details string) *CacheError + func (e *CacheError) WithFile(file string) *CacheError + func (e *CacheError) WithPath(path string) *CacheError + type CacheOption func(c *DiskCache) + func WithBatchSize(size int64) CacheOption + func WithCapacity(size int64) CacheOption + func WithDirPermission(perms os.FileMode) CacheOption + func WithExtraCapacity(size int64) CacheOption + func WithFILODrop(on bool) CacheOption + func WithFilePermission(perms os.FileMode) CacheOption + func WithMaxDataSize(size int32) CacheOption + func WithNoDrop(on bool) CacheOption + func WithNoFallbackOnError(on bool) CacheOption + func WithNoLock(on bool) CacheOption + func WithNoPos(on bool) CacheOption + func WithNoSync(on bool) CacheOption + func WithPath(x string) CacheOption + func WithPosUpdate(cnt int, du time.Duration) CacheOption + func WithWakeup(wakeup time.Duration) CacheOption + type DiskCache struct + LastErr error + func Open(opts ...CacheOption) (*DiskCache, error) + func (c *DiskCache) BufCallbackGet(bfn BufFunc, fn Fn) error + func (c *DiskCache) BufGet(buf []byte, fn Fn) error + func (c *DiskCache) Capacity() int64 + func (c *DiskCache) Close() error + func (c *DiskCache) Get(fn Fn) error + func (c *DiskCache) IsFull(newData []byte) bool + func (c *DiskCache) MaxBatchSize() int64 + func (c *DiskCache) MaxDataSize() int32 + func (c *DiskCache) Path() string + func (c *DiskCache) Pretty() string + func (c *DiskCache) Put(data []byte) error + func (c *DiskCache) RawSize() int64 + func (c *DiskCache) Rotate() error + func (c *DiskCache) Size() int64 + func (c *DiskCache) StreamPut(r io.Reader, size int) error + func (c *DiskCache) String() string + type Fn func([]byte) error + type InstrumentedMutex struct + func NewInstrumentedMutex(lockType LockType, path string, lockWaitTime *prometheus.HistogramVec, ...) *InstrumentedMutex + func (im *InstrumentedMutex) Lock() + func (im *InstrumentedMutex) TryLock() bool + func (im *InstrumentedMutex) Unlock() + type InstrumentedRWMutex struct + func NewInstrumentedRWMutex(path string, lockWaitTime *prometheus.HistogramVec, ...) *InstrumentedRWMutex + func (irm *InstrumentedRWMutex) Lock() + func (irm *InstrumentedRWMutex) RLock() + func (irm *InstrumentedRWMutex) RUnlock() + func (irm *InstrumentedRWMutex) TryLock() bool + func (irm *InstrumentedRWMutex) TryRLock() bool + func (irm *InstrumentedRWMutex) Unlock() + type LockType string + const LockTypeRW + const LockTypeRead + const LockTypeWrite + type Operation string + const OpClose + const OpCreate + const OpDrop + const OpGet + const OpLock + const OpOpen + const OpPos + const OpPut + const OpRead + const OpRemove + const OpRename + const OpRotate + const OpSeek + const OpStat + const OpStreamPut + const OpSwitch + const OpSync + const OpUnlock + const OpWrite Other modules containing this package github.com/GuanceCloud/cliutils