youbbs
youbbs
3159 0 0

cdb:一个快速、可靠、简单的包,用于创建和读取常量数据库

cdb是一个快速,可靠,简单的包,用于创建和读取常量数据库,当不想引入复杂的数据库时,可以选择这样简单的数据库,作为快速存取。

f, _ := os.Create("test.cdb")
defer f.Close()

handle := cdb.New()

data := []struct {
    key, value string
}{
    {"key1", "value1"},
    {"key2", "value2"},
    {"key3", "value3"},
    {"key4", "value4"},
    {"key5", "value5"},
    {"key6", "value6"},
    {"key7", "value7"},
}

writer, err := handle.GetWriter(f)
if err != nil {
    t.Error(err)
}

for _, c := range data {
    writer.Put([]byte(c.key), []byte(c.value))
}

writer.Close()
reader, _ := handle.GetReader(f)

for _, c := range data {
    value, err := reader.Get([]byte(c.key))
}

https://github.com/alldroll/cdb

0

See Also

Nearby


Discussion

Login Topics