Fix ineffassign (#388)

* Fix ineffassign

* upgrade readme
This commit is contained in:
Lunny Xiao 2020-05-10 20:54:36 +08:00 committed by GitHub
parent eb6693a86b
commit b814d6a929
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 53 deletions

View File

@ -26,14 +26,16 @@ LedisDB now supports multiple different databases as backends.
Create a workspace and checkout ledisdb source Create a workspace and checkout ledisdb source
git clone git@github.com:ledisdb/ledisdb.git ```shell
cd ledisdb git clone git@github.com:ledisdb/ledisdb.git
cd ledisdb
#set build and run environment #set build and run environment
source dev.sh source dev.sh
make make
make test make test
```
Then you will find all the binary build on `./bin` directory. Then you will find all the binary build on `./bin` directory.
@ -65,7 +67,6 @@ Then you will find all the binary build on `./bin` directory.
If the RocksDB API changes, LedisDB may not build successfully. LedisDB currently supports RocksDB version 5.1 or later. If the RocksDB API changes, LedisDB may not build successfully. LedisDB currently supports RocksDB version 5.1 or later.
## Choose store database ## Choose store database
@ -75,13 +76,13 @@ Choosing a store database to use is very simple.
+ Set in server config file + Set in server config file
db_name = "leveldb" db_name = "leveldb"
+ Set in command flag + Set in command flag
ledis-server -config=/etc/ledis.conf -db_name=leveldb ledis -config=/etc/ledis.conf -db_name=leveldb
Flag command set will overwrite config setting. Flag command set will overwrite config setting.
## Lua support ## Lua support
@ -94,53 +95,58 @@ LedisDB uses [toml](https://github.com/toml-lang/toml) as the configuration form
If you don't use a configuration, LedisDB will use the default for you. If you don't use a configuration, LedisDB will use the default for you.
## Server Example ## Server Example
//set run environment if not
source dev.sh
./bin/ledis-server -config=/etc/ledis.conf ```shell
//set run environment if not
source dev.sh
//another shell ./bin/ledis -config=/etc/ledis.conf
./bin/ledis-cli -p 6380
ledis 127.0.0.1:6380> set a 1
OK
ledis 127.0.0.1:6380> get a
"1"
//use curl //another shell
curl http://127.0.0.1:11181/SET/hello/world ./bin/ledis cli -p 6380
→ {"SET":[true,"OK"]}
curl http://127.0.0.1:11181/0/GET/hello?type=json ledis 127.0.0.1:6380> set a 1
→ {"GET":"world"} OK
ledis 127.0.0.1:6380> get a
"1"
//use curl
curl http://127.0.0.1:11181/SET/hello/world
→ {"SET":[true,"OK"]}
curl http://127.0.0.1:11181/0/GET/hello?type=json
→ {"GET":"world"}
```
## Package Example ## Package Example
import (
lediscfg "github.com/ledisdb/ledisdb/config"
"github.com/ledisdb/ledisdb/ledis"
)
# Use Ledis's default config ```go
cfg := lediscfg.NewConfigDefault() import (
l, _ := ledis.Open(cfg) lediscfg "github.com/ledisdb/ledisdb/config"
db, _ := l.Select(0) "github.com/ledisdb/ledisdb/ledis"
)
db.Set(key, value) # Use Ledis's default config
cfg := lediscfg.NewConfigDefault()
l, _ := ledis.Open(cfg)
db, _ := l.Select(0)
db.Get(key) db.Set(key, value)
db.Get(key)
```
## Replication Example ## Replication Example
Set slaveof in config or dynamiclly Set slaveof in config or dynamiclly
ledis-cli -p 6381 ```shell
ledis cli -p 6381
ledis 127.0.0.1:6381> slaveof 127.0.0.1 6380 ledis 127.0.0.1:6381> slaveof 127.0.0.1 6380
OK OK
```
## Cluster support ## Cluster support
@ -180,7 +186,6 @@ See [Clients](https://github.com/ledisdb/ledisdb/wiki/Clients) to find or contri
+ [pika](https://github.com/Qihoo360/pika) + [pika](https://github.com/Qihoo360/pika)
## Donate ## Donate
If you like the project and want to buy me a cola, you can through: If you like the project and want to buy me a cola, you can through:

View File

@ -106,13 +106,7 @@ func (l *Ledis) Dump(w io.Writer) error {
} }
} }
if err = wb.Flush(); err != nil { return wb.Flush()
return err
}
compressBuf = nil
return nil
} }
// LoadDumpFile clears all data and loads dump file to db // LoadDumpFile clears all data and loads dump file to db
@ -207,9 +201,6 @@ func (l *Ledis) LoadDump(r io.Reader) (*DumpHead, error) {
return nil, err return nil, err
} }
deKeyBuf = nil
deValueBuf = nil
if l.r != nil { if l.r != nil {
if err := l.r.UpdateCommitID(h.CommitID); err != nil { if err := l.r.UpdateCommitID(h.CommitID); err != nil {
return nil, err return nil, err

View File

@ -123,7 +123,7 @@ func (s *FileStore) GetLog(id uint64, l *Log) error {
} }
func (s *FileStore) FirstID() (uint64, error) { func (s *FileStore) FirstID() (uint64, error) {
id := uint64(0) var id uint64
s.rm.RLock() s.rm.RLock()
if len(s.rs) > 0 { if len(s.rs) > 0 {
@ -408,7 +408,6 @@ func (ts tableReaders) check() error {
return fmt.Errorf("invalid index %d in table %s", ts[i].index, ts[i]) return fmt.Errorf("invalid index %d in table %s", ts[i].index, ts[i])
} }
first = ts[i].first
last = ts[i].last last = ts[i].last
index = ts[i].index index = ts[i].index
} }