Esempio n. 1
0
File: cmd.go Progetto: yuya008/godis
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)
}
Esempio n. 2
0
File: ts.go Progetto: yuya008/godis
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,
	}
}
Esempio n. 3
0
File: ts.go Progetto: yuya008/godis
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
}
Esempio n. 4
0
File: ts.go Progetto: yuya008/godis
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())
	}
}
Esempio n. 5
0
File: cmd.go Progetto: yuya008/godis
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)
}