func cmdDbs(c *Client) { dbs := c.godis.Dbs list := ds.NewList() for i := 0; i < len(dbs); i++ { list.Put(ds.CreateObjectFromString(strconv.Itoa(int(dbs[i].Id)), 0)) list.Put(ds.CreateObjectFromString(dbs[i].DbName, 0)) } reply(c, success, list) }
func NewTs(godis *Godis) *Ts { return &Ts{ TsId: atomic.AddUint64(&TsGlobalId, 1), timeout: godis.Tstimeout, tsrList: ds.NewList(), magicDB: make(map[string]*ds.Object), datalog: godis.Dl, tsLog: godis.Tl, } }
func (ts *Ts) GetDBKeys(db *db.DB) ds.List { list := ds.NewList() for key, _ := range db.Data { list.Put(ds.CreateObject([]byte(key), ds.BIN, ts.TsId)) } for key, _ := range ts.magicDB { list.Put(ds.CreateObject([]byte(key), ds.BIN, ts.TsId)) } return list }
func (ts *Ts) storeTsr() { var tsr *TsRecord var ok bool list := ds.NewList() for e := ts.tsrList.GetFirstNode(); e != nil; e = e.Next { if tsr, ok = e.Value.(*TsRecord); !ok { continue } if tsr.Position != nil { list.Put(tsr.Position) } } if list.Len() == 0 { return } ts.position = ts.tsLog.PutAMeta(store.Commit, ts.TsId, list) if ts.position == nil { log.Panicln("storeTsr()", list.Len()) } }
func cmdSget(c *Client) { if !c.ts.RlockDB(c.CurDB) { reply(c, err_ts_lock_timeout.Error(), nil) return } defer c.ts.UnLockDB(c.CurDB) args, err := getArgs(c) if err != nil { reply(c, err.Error(), nil) return } list := ds.NewList() for _, key := range args { obj := c.ts.GetDBKey(c.CurDB, key) if obj != nil { list.Put(obj) } } reply(c, success, list) }