
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
github.com/Livbz/mossdb
MossDB is a in-memory, persistent and embedded key-value store.
Features:
The architecture of MossDB as follows:
To start using MossDB, just use go get:
go get github.com/qingwave/mossdb
There is a simple example shows how to use MossDB.
package main
import (
"context"
"errors"
"log"
"time"
"github.com/qingwave/mossdb"
)
func () {
// create db instance
db, err := mossdb.New(&mossdb.Config{})
if err != nil {
log.Fatal(err)
}
// set, get, delete data
db.Set("key1", []byte("val1"))
log.Printf("get key1: %s", db.Get("key1"))
db.Delete("key1", []byte("val1"))
}
The database allows for rich transactions, in which multiple objects are inserted, updated or deleted. Note that one transaction allowed at a time.
db.Tx(func(tx *mossdb.Tx) error {
val1 := tx.Get("key1")
tx.Set("key2", val1)
return nil
})
Watch interface just like etcd Watch(watch a key or prefix key), caller will receive event when the watched keys modified.
func Watch(db *mossdb.DB) {
key := "watch-key"
go func() {
db.Set(key, mossdb.Val("val1"))
db.Set(key, mossdb.Val("val2"))
db.Delete(key)
time.Sleep(100 * time.Second)
db.Set(key, mossdb.Val("val3"))
}()
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
defer cancel()
ch := db.Watch(ctx, key)
for {
select {
case <-ctx.Done():
log.Printf("context done")
return
case resp, ok := <-ch:
if !ok {
log.Printf("watch done")
return
}
log.Printf("receive event: %s, key: %s, new val: %s", resp.Event.Op, resp.Event.Key, resp.Event.Val)
}
}
}
Key with expired time in useful sometimes, MossDB use a time heap to expire key near real-time.
db.Set("key-ttl", []byte("val-ttl"), mossdb.WithTTL(100*time.Millisecond))
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.