Documentation ¶
Index ¶
- Variables
- func Bson(v interface{}) []byte
- func Close() error
- func Load(file string) error
- func Open(opt Option) error
- func PKCS7Padding(ciphertext []byte, blksize int) []byte
- func PKCS7UnPadding(origData []byte) []byte
- func Put(key, value []byte, actionFunc ...func(action *Action)) (err error)
- func Remove(key []byte)
- func SetEncryptor(encryptor Encryptor, secret []byte)
- func SetHashFunc(hash Hashed)
- func SetIndexSize(size int32)
- func TTL(second uint32) func(action *Action)
- type AESEncryptor
- type Action
- type Data
- type Encoder
- type Encryptor
- type Hashed
- type Item
- type Log
- type Option
- type SourceData
Constants ¶
This section is empty.
Variables ¶
var ( // Root Data storage directory Root = "" // FRW Read-only Opens a file in write - only mode FRW = os.O_RDWR | os.O_APPEND | os.O_CREATE // FR Open the file in read-only mode FR = os.O_RDONLY // Perm Default file operation permission Perm = os.FileMode(0750) // HashedFunc Default Hashed function HashedFunc Hashed // Secret encryption key Secret = []byte("ME:QQ:2420498526") )
Bottle storage engine components
var ( // DefaultOption default initialization option DefaultOption = Option{ Directory: "./data", DataFileMaxSize: 10240, } )
Functions ¶
func PKCS7Padding ¶
PKCS7Padding complement
func SetEncryptor ¶
SetEncryptor Set up a custom encryption implementation
func SetIndexSize ¶
func SetIndexSize(size int32)
SetIndexSize set the expected index size to prevent secondary memory allocation and data migration during running
Types ¶
type AESEncryptor ¶
type AESEncryptor struct{}
AESEncryptor Implement the Encryptor interface
func (AESEncryptor) Decode ¶
func (AESEncryptor) Decode(sd *SourceData) error
Decode source data decode
func (AESEncryptor) Encode ¶
func (AESEncryptor) Encode(sd *SourceData) error
Encode source data encode
type Encoder ¶
type Encoder struct { Encryptor // encryptor concrete implementation // contains filtered or unexported fields }
Encoder bytes data encoder
func DefaultEncoder ¶
func DefaultEncoder() *Encoder
DefaultEncoder disable the AES encryption encoder
type Encryptor ¶
type Encryptor interface { Encode(sd *SourceData) error Decode(sd *SourceData) error }
Encryptor used for data encryption and decryption operation
type Hashed ¶
Hashed is responsible for generating unsigned, 64-bit hash of provided string. Harsher should minimize collisions (generating same hash for different strings) and while performance is also important fast functions are preferable (i.e. you can use FarmHash family).
func DefaultHashFunc ¶
func DefaultHashFunc() Hashed
DefaultHashFunc returns a new 64-bit FNV-1a Hashed which makes no memory allocations. Its Sum64 method will lay the value out in big-endian byte order. See https://en.wikipedia.org/wiki/Fowler–Noll–Vo_hash_function
type Item ¶
type Item struct { TimeStamp uint64 // Create timestamp CRC32 uint32 // Cyclic check code KeySize uint32 // The size of the key ValueSize uint32 // The size of the value Log // Key string, value serialization }
Item each data operation log item | TS 8 | CRC 4 | KS 4 | VS 4 | KEY ? | VALUE ? | ItemPadding = 8 + 12 = 20 byte 20 * 8 = 160 bit
type Option ¶
type Option struct { Directory string `yaml:"Directory"` // data directory DataFileMaxSize int64 `yaml:"DataFileMaxSize"` // data file max size Enable bool `yaml:"Enable"` // data whether to enable encryption Secret string `yaml:"Secret"` // data encryption key }
Option bottle setting option
type SourceData ¶
SourceData for encryption and decryption