示例#1
0
文件: ts.go 项目: yuya008/godis
func (ts *Ts) rollbackDbDel(db *db.DB, key []byte) {
	obj := ts.getMagicDb(key)
	if obj != nil {
		db.SetDbObj(key, obj)
	}
	ts.delMagicDb(key)
}
示例#2
0
文件: ts.go 项目: yuya008/godis
func (ts *Ts) commitDbAdd(db *db.DB, key []byte) {
	obj := ts.getMagicDb(key)
	log.Println("Obj", obj)
	if obj != nil {
		ts.datalog.PutKeyValue(db, key, store.None, obj)
		db.SetDbObj(key, obj)
	}
}
示例#3
0
文件: ts.go 项目: yuya008/godis
func (ts *Ts) DeleteDBKey(db *db.DB, key []byte) {
	var err error
	tsr := NewTsRecord(DeleteDbKey)
	tsr.Key = key
	tsr.Dbptr = db
	if origObj := db.GetDbObj(key); origObj != nil {
		tsr.Position = ts.tsLog.Put(db, origObj.GetObjectType(), key,
			origObj.GetBuffer())
		if tsr.Position == nil {
			log.Panicln(err)
		}
	}
	ts.AddTsRecord(tsr)
	obj := ts.getMagicDb(key)
	if obj != nil {
		ts.delMagicDb(key)
	} else {
		obj = db.GetDbObj(key)
		if obj != nil {
			ts.setMagicDb(key, obj)
			db.DeleteDbObj(key)
		}
	}
}
示例#4
0
文件: ts.go 项目: yuya008/godis
func (ts *Ts) SetDBKey(db *db.DB, t uint8, key []byte, value []byte) {
	var err error
	tsr := NewTsRecord(AddDbKey)
	if origObj := db.GetDbObj(key); origObj != nil {
		log.Println("SetDBKey() origObj:", origObj)
		tsr.Position = ts.tsLog.Put(db, origObj.GetObjectType(), key,
			origObj.GetBuffer())
		if tsr.Position == nil {
			log.Panicln(err)
		}
	}
	tsr.Key = key
	tsr.Dbptr = db
	ts.AddTsRecord(tsr)
	ts.setMagicDb(key, ds.CreateObject(value, t, ts.TsId))
}
示例#5
0
文件: ts.go 项目: yuya008/godis
func (ts *Ts) GetDBKey(db *db.DB, key []byte) *ds.Object {
	if obj := ts.getMagicDb(key); obj != nil {
		return obj
	}
	return db.GetDbObj(key)
}