Documentation ¶
Index ¶
- Constants
- Variables
- func Compress(data []byte) ([]byte, error)
- func Decompress(data []byte) ([]byte, error)
- func DetectLang(content string) string
- func DetectType(name string, content string) (string, bool)
- func IsBZIP2(b []byte) bool
- func IsBZip2(r io.ReaderAt) (bool, error)
- func IsDEB(b []byte) bool
- func IsGZIP(b []byte) bool
- func IsGZip(r io.ReaderAt) (bool, error)
- func IsISO(b []byte) bool
- func IsJSON(b []byte) bool
- func IsLZ4(r io.ReaderAt) (bool, error)
- func IsLZH(b []byte) bool
- func IsLZMA(b []byte) bool
- func IsRAR(b []byte) bool
- func IsTar(r io.ReaderAt) (bool, error)
- func IsXAR(b []byte) bool
- func IsXZ(b []byte) bool
- func IsYAML(b []byte) bool
- func IsZIP(b []byte) bool
- func IsZLib(b []byte) bool
- func IsZip(r io.ReaderAt) (bool, error)
- func Match(pattern string, in []byte) bool
- func ReadHeader(content string)
- func SubString(pattern string, in []byte) bool
- type Cache
- type Check
- type Config
- type Format
Constants ¶
const ( // GzipMinSize gzip min size GzipMinSize = 1024 // CacheFormatRaw raw CacheFormatRaw = 0 // CacheFormatRawGzip raw gzip CacheFormatRawGzip = 1 // CacheFormatJSON json CacheFormatJSON = 10 // CacheFormatJSONGzip json gzip CacheFormatJSONGzip = 11 )
Variables ¶
var ( ErrUnknown = errors.New("unknown compression format") ErrEmpty = errors.New("no data to read") )
var ( PluginConfig = &badgercacheConfig{ done: make(chan struct{}), } )
Config ...
Functions ¶
func Decompress ¶
func DetectLang ¶
func IsBZip2 ¶
IsBZip2 checks to see if the received reader's contents are in bzip2 format by checking the magic numbers.
func IsGZip ¶
IsGZip checks to see if the received reader's contents are in gzip format by checking the magic numbers.
func IsLZ4 ¶
IsLZ4 checks to see if the received reader's contents are in LZ4 foramt by checking the magic numbers.
func IsTar ¶
IsTar checks to see if the received reader's contents are in the tar format by checking the magic numbers. This evaluates using both tar1 and tar2 magic numbers.
func IsZip ¶
IsZip checks to see if the received reader's contents are in the zip format by checking the magic numbers. This will match on zip, empty zip and spanned zip magic numbers. If you need to distinguish between those, use something else.
func ReadHeader ¶
func ReadHeader(content string)
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache stores and retrieves data using Badger KV.
type Config ¶
type Config struct { Debug bool Compress bool // 1. Mandatory flags // ------------------- // Directory to store the data in. Should exist and be writable. StoragePath string // Dir // Directory to store the value log in. Can be the same as Dir. Should // exist and be writable. ValueDir string // 2. Frequently modified flags // ----------------------------- // Sync all writes to disk. Setting this to true would slow down data // loading significantly. SyncWrites bool // 3. Flags that user might want to review // ---------------------------------------- // The following affect all levels of LSM tree. MaxTableSize int64 // Each table (or file) is at most this size. LevelSizeMultiplier int // Equals SizeOf(Li+1)/SizeOf(Li). MaxLevels int // Maximum number of levels of compaction. // If value size >= this threshold, only store value offsets in tree. ValueThreshold int // Maximum number of tables to keep in memory, before stalling. NumMemtables int // The following affect how we handle LSM tree L0. // Maximum number of Level 0 tables before we start compacting. NumLevelZeroTables int // If we hit this number of Level 0 tables, we will stall until L0 is // compacted away. NumLevelZeroTablesStall int // Maximum total size for L1. LevelOneSize int64 // Size of single value log file. ValueLogFileSize int64 // Number of compaction workers to run concurrently. NumCompactors int // 4. Flags for testing purposes // ------------------------------ DoNotCompact bool // Stops LSM tree from compactions. }
type Format ¶
type Format int
const ( Unknown Format = iota // unknown format GZip // Gzip compression format BZip2 // Bzip2 compression LZ4 // LZ4 compression Tar // Tar format; normally used Tar1 // Tar1 magicnum format; normalizes to Tar Tar2 // Tar1 magicnum format; normalizes to Tar Zip // Zip archive ZipEmpty // Empty Zip Archive ZipSpanned // Spanned Zip Archive )
func GetFormat ¶
GetFormat tries to match up the data in the Reader to a supported magic number, if a match isn't found, UnsupportedFmt is returned
For zips, this will also match on files with empty zip or spanned zip magic numbers. If you need to distinguich between the various zip formats, use something else.
func ParseFormat ¶
ParseFormat takes a string and returns the format or unknown. Any compressed tar extensions are returned as the compression format and not tar.
If the passed string starts with a '.', it is removed. All strings are lowercased