Hybrid memory/disk map that helps you to manage key value storage for input deduplication.
Available functions:
| Name | Declaration/Params/Return |
|---|---|
| New | func New(options Options) (*HybridMap, error){} |
| Close | func (hm *HybridMap) Close() error{} |
| Set | func (hm *HybridMap) Set(k string, v []byte) error{} |
| Get | func (hm *HybridMap) Get(k string) ([]byte, bool){} |
| Del | func (hm *HybridMap) Del(key string) error{} |
| Scan | func (hm *HybridMap) Scan(f func([]byte, []byte) error){} |
| Size | func (hm *HybridMap) Size() int64{} |
| TuneMemory | func (hm *HybridMap) TuneMemory(){} |
Available options:
const (
MemoryMapType=iotaDiskHybrid
)
typeDBTypeintconst (
LevelDBDBType=iotaPogrebDBBBoltDBBuntDB
)| Name | Props |
|---|---|
DefaultOptions | - Type: Memory - MemoryExpirationTime: time.Duration(5) * time.Minute - JanitorTime: time.Duration(1) * time.Minute |
DefaultMemoryOptions | - Type: Memory |
DefaultDiskOptions | - Type: Disk - DBType: LevelDB - Cleanup: true - RemoveOlderThan: 24* time.Hour *2 |
DefaultDiskOptions | - Type: Hybrid - DBType: PogrebDB - MemoryExpirationTime: time.Duration(5) * time.Minute - JanitorTime: time.Duration(1) * time.Minute |
Custom options:
typeOptionsstruct {
MemoryExpirationTime time.DurationDiskExpirationTime time.DurationJanitorTime time.DurationTypeMapTypeDBTypeDBTypeMemoryGuardForceDiskboolMemoryGuardboolMaxMemorySizeintMemoryGuardTime time.DurationPathstringCleanupboolNamestringRemoveOlderThan time.Duration
}funcmain() {
varwg sync.WaitGroupwg.Add(1)
gonormal(&wg)
wg.Wait()
}
funcnormal(wg*sync.WaitGroup) {
deferwg.Done()
hm, err:=hybrid.New(hybrid.DefaultOptions)
iferr!=nil {
log.Fatal(err)
}
deferhm.Close()
err2:=hm.Set("a", []byte("b"))
iferr2!=nil {
log.Fatal(err2)
}
v, ok:=hm.Get("a")
ifok {
log.Println(v)
}
}hmap is distributed under MIT License