llgo:rust:sled:a working demo
This commit is contained in:
@@ -6,11 +6,12 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
//c.Printf(c.Str("helloworld\n"))
|
||||
var valueLen c.Ulong
|
||||
conf := &sled.SledConfig{}
|
||||
conf.SetPath(c.Str("./db.sled"))
|
||||
db := conf.OpenDB()
|
||||
conf := sled.CreateConfig()
|
||||
path := c.Str("./db")
|
||||
copyPath := c.Strdup(path)
|
||||
pathConfig := conf.SetPath(copyPath)
|
||||
db := pathConfig.OpenDb()
|
||||
db.Set(c.Str("key"), 3, c.Str("value"), 5)
|
||||
value := db.Get(c.Str("key"), 3, &valueLen)
|
||||
c.Printf(c.Str("value: %s\n"), value)
|
||||
|
||||
@@ -15,21 +15,56 @@ type SledDb struct {
|
||||
Unused [8]byte
|
||||
}
|
||||
|
||||
//llgo:link (*SledConfig).SetPath C.sled_config_set_path
|
||||
func (conf *SledConfig) SetPath(char *c.Char) *SledConfig {
|
||||
return nil
|
||||
}
|
||||
// Create a new configuration
|
||||
// llgo:link CreateConfig C.sled_create_config
|
||||
func CreateConfig() *SledConfig { return nil }
|
||||
|
||||
//llgo:link (*SledConfig).OpenDB C.sled_open_db
|
||||
func (conf *SledConfig) OpenDB() *SledDb {
|
||||
return nil
|
||||
}
|
||||
// Free a configuration
|
||||
// llgo:link (*SledConfig).FreeConfig C.sled_free_config
|
||||
func (conf *SledConfig) FreeConfig() {}
|
||||
|
||||
//llgo:link (*SledDb).Set C.sled_set
|
||||
func (db *SledDb) Set(key *c.Char, keyLen c.Ulong, value *c.Char, valueLen c.Ulong) {
|
||||
}
|
||||
// Set the configured file path
|
||||
// llgo:link (*SledConfig).SetPath C.sled_config_set_path
|
||||
func (conf *SledConfig) SetPath(path *c.Char) *SledConfig { return nil }
|
||||
|
||||
//llgo:link (*SledDb).Get C.sled_get
|
||||
func (db *SledDb) Get(key *c.Char, keyLen c.Ulong, valLen *c.Ulong) *c.Char {
|
||||
return nil
|
||||
// Set the configured cache capacity in bytes
|
||||
// llgo:link (*SledConfig).SetCacheCapacity C.sled_config_set_cache_capacity
|
||||
func (conf *SledConfig) SetCacheCapacity(capacity c.Ulong) *SledConfig { return nil }
|
||||
|
||||
// Configure the use of the zstd compression library
|
||||
// llgo:link (*SledConfig).UseCompression C.sled_config_use_compression
|
||||
func (conf *SledConfig) UseCompression(use_compression c.Char) *SledConfig { return nil }
|
||||
|
||||
// Set the configured IO buffer flush interval in milliseconds
|
||||
// llgo:link (*SledConfig).SetFlushEveryMs C.sled_config_flush_every_ms
|
||||
func (conf *SledConfig) SetFlushEveryMs(flush_every c.Int) *SledConfig { return nil }
|
||||
|
||||
// Open a sled lock-free log-structured tree
|
||||
// llgo:link (*SledConfig).OpenDb C.sled_open_db
|
||||
func (conf *SledConfig) OpenDb() *SledDb { return nil }
|
||||
|
||||
// Close a sled lock-free log-structured tree
|
||||
// llgo:link (*SledDb).Close C.sled_close
|
||||
func (db *SledDb) Close() {}
|
||||
|
||||
// Free a buffer originally allocated by sled
|
||||
// llgo:link FreeBuf C.sled_free_buf
|
||||
func FreeBuf(buf *c.Char, sz c.Ulong) {}
|
||||
|
||||
// Set a key to a value
|
||||
// llgo:link (*SledDb).Set C.sled_set
|
||||
func (db *SledDb) Set(key *c.Char, keylen c.Ulong, val *c.Char, vallen c.Ulong) {}
|
||||
|
||||
// Get the value of a key
|
||||
// llgo:link (*SledDb).Get C.sled_get
|
||||
func (db *SledDb) Get(key *c.Char, keylen c.Ulong, vallen *c.Ulong) *c.Char { return nil }
|
||||
|
||||
// Delete the value of a key
|
||||
// llgo:link (*SledDb).Del C.sled_del
|
||||
func (db *SledDb) Del(key *c.Char, keylen c.Ulong) {}
|
||||
|
||||
// Compare and swap
|
||||
// llgo:link (*SledDb).CompareAndSwap C.sled_compare_and_swap
|
||||
func (db *SledDb) CompareAndSwap(key *c.Char, keylen c.Ulong, old_val *c.Char, old_vallen c.Ulong, new_val *c.Char, new_vallen c.Ulong, actual_val **c.Char, actual_vallen *c.Ulong) c.Char {
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user