update documents

This commit is contained in:
siddontang 2014-07-09 09:33:44 +08:00
parent 7f6cb9a52f
commit dfb9c90412
6 changed files with 22 additions and 19 deletions

View File

@ -80,6 +80,7 @@ Some server commands explaintions are [here](https://github.com/siddontang/ledis
## Thanks ## Thanks
Gmail: cenqichao@gmail.com Gmail: cenqichao@gmail.com
Gmail: chendahui007@gmail.com Gmail: chendahui007@gmail.com
## Feedback ## Feedback

View File

@ -86,6 +86,7 @@ ledisdb是一个用go实现的类似redis的高性能nosql数据库底层基
## 感谢 ## 感谢
Gmail: cenqichao@gmail.com Gmail: cenqichao@gmail.com
Gmail: chendahui007@gmail.com Gmail: chendahui007@gmail.com
## 联系我 ## 联系我

View File

@ -15,6 +15,7 @@ import (
// |keylen(bigendian int32)|key|valuelen(bigendian int32)|value...... // |keylen(bigendian int32)|key|valuelen(bigendian int32)|value......
// //
//key and value are both compressed for fast transfer dump on network using snappy //key and value are both compressed for fast transfer dump on network using snappy
type MasterInfo struct { type MasterInfo struct {
LogFileIndex int64 LogFileIndex int64
LogPos int64 LogPos int64

View File

@ -150,7 +150,7 @@ func (l *Ledis) FlushAll() error {
return nil return nil
} }
//very dangerous to use // very dangerous to use
func (l *Ledis) DataDB() *leveldb.DB { func (l *Ledis) DataDB() *leveldb.DB {
return l.ldb return l.ldb
} }

View File

@ -1,4 +1,4 @@
//a wrapper for c++ leveldb // Package leveldb is a wrapper for c++ leveldb
package leveldb package leveldb
/* /*

View File

@ -23,12 +23,12 @@ const (
RangeOpen uint8 = 0x11 RangeOpen uint8 = 0x11
) )
//min must less or equal than max // min must less or equal than max
//range type: // range type:
//close: [min, max] // close: [min, max]
//open: (min, max) // open: (min, max)
//lopen: (min, max] // lopen: (min, max]
//ropen: [min, max) // ropen: [min, max)
type Range struct { type Range struct {
Min []byte Min []byte
Max []byte Max []byte
@ -46,7 +46,7 @@ type Iterator struct {
isValid C.uchar isValid C.uchar
} }
//Returns a copy of key. // Returns a copy of key.
func (it *Iterator) Key() []byte { func (it *Iterator) Key() []byte {
var klen C.size_t var klen C.size_t
kdata := C.leveldb_iter_key(it.it, &klen) kdata := C.leveldb_iter_key(it.it, &klen)
@ -57,7 +57,7 @@ func (it *Iterator) Key() []byte {
return C.GoBytes(unsafe.Pointer(kdata), C.int(klen)) return C.GoBytes(unsafe.Pointer(kdata), C.int(klen))
} }
//Returns a copy of value. // Returns a copy of value.
func (it *Iterator) Value() []byte { func (it *Iterator) Value() []byte {
var vlen C.size_t var vlen C.size_t
vdata := C.leveldb_iter_value(it.it, &vlen) vdata := C.leveldb_iter_value(it.it, &vlen)
@ -68,8 +68,8 @@ func (it *Iterator) Value() []byte {
return C.GoBytes(unsafe.Pointer(vdata), C.int(vlen)) return C.GoBytes(unsafe.Pointer(vdata), C.int(vlen))
} }
//Returns a reference of key. // Returns a reference of key.
//you must be careful that it will be changed after next iterate. // you must be careful that it will be changed after next iterate.
func (it *Iterator) RawKey() []byte { func (it *Iterator) RawKey() []byte {
var klen C.size_t var klen C.size_t
kdata := C.leveldb_iter_key(it.it, &klen) kdata := C.leveldb_iter_key(it.it, &klen)
@ -80,8 +80,8 @@ func (it *Iterator) RawKey() []byte {
return slice(unsafe.Pointer(kdata), int(C.int(klen))) return slice(unsafe.Pointer(kdata), int(C.int(klen)))
} }
//Returns a reference of value. // Returns a reference of value.
//you must be careful that it will be changed after next iterate. // you must be careful that it will be changed after next iterate.
func (it *Iterator) RawValue() []byte { func (it *Iterator) RawValue() []byte {
var vlen C.size_t var vlen C.size_t
vdata := C.leveldb_iter_value(it.it, &vlen) vdata := C.leveldb_iter_value(it.it, &vlen)
@ -92,7 +92,7 @@ func (it *Iterator) RawValue() []byte {
return slice(unsafe.Pointer(vdata), int(C.int(vlen))) return slice(unsafe.Pointer(vdata), int(C.int(vlen)))
} }
//Copy key to b, if b len is small or nil, returns a new one // Copy key to b, if b len is small or nil, returns a new one
func (it *Iterator) BufKey(b []byte) []byte { func (it *Iterator) BufKey(b []byte) []byte {
k := it.RawKey() k := it.RawKey()
if k == nil { if k == nil {
@ -106,7 +106,7 @@ func (it *Iterator) BufKey(b []byte) []byte {
return append(b, k...) return append(b, k...)
} }
//Copy value to b, if b len is small or nil, returns a new one // Copy value to b, if b len is small or nil, returns a new one
func (it *Iterator) BufValue(b []byte) []byte { func (it *Iterator) BufValue(b []byte) []byte {
v := it.RawValue() v := it.RawValue()
if v == nil { if v == nil {
@ -150,7 +150,7 @@ func (it *Iterator) Seek(key []byte) {
it.isValid = C.leveldb_iter_seek_ext(it.it, (*C.char)(unsafe.Pointer(&key[0])), C.size_t(len(key))) it.isValid = C.leveldb_iter_seek_ext(it.it, (*C.char)(unsafe.Pointer(&key[0])), C.size_t(len(key)))
} }
//Finds by key, if not found, nil returns // Finds by key, if not found, nil returns
func (it *Iterator) Find(key []byte) []byte { func (it *Iterator) Find(key []byte) []byte {
it.Seek(key) it.Seek(key)
if it.Valid() { if it.Valid() {
@ -165,8 +165,8 @@ func (it *Iterator) Find(key []byte) []byte {
return nil return nil
} }
//Finds by key, if not found, nil returns, else a reference of value returns // Finds by key, if not found, nil returns, else a reference of value returns
//you must be careful that it will be changed after next iterate. // you must be careful that it will be changed after next iterate.
func (it *Iterator) RawFind(key []byte) []byte { func (it *Iterator) RawFind(key []byte) []byte {
it.Seek(key) it.Seek(key)
if it.Valid() { if it.Valid() {