Example #1
0
File: ts.go Project: 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)
		}
	}
}
Example #2
0
File: ts.go Project: 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))
}
Example #3
0
File: ts.go Project: 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)
}