// sync data into low level db, cache remain one hour data
sync data into low level db, cache remain one hour data
// sync data into low level db cache remain one hour data
func sync_data() {
	ticker := time.Tick(timeSeg)
	for range ticker {
		log.Debug("sync data start...")
		ts := wal.NewOffsetForTS(time.Now().Add(-1 * timeSeg))
		wr, err := gWal.NewReader("sync", ts, gBytePool.Get)
		if err != nil {
			log.Error(err)
			return
		}
		for {
			data, err := wr.Read()
			if err != nil {
				log.Error(err)
				break
			}
			key, val, err := codec.ExtactKeyAndValue(data)
			if err != nil {
				log.Error("error command record: ", tools.BytesToStringFast(data))
				break
			}
			gKVClient.Set(key, val)
		}
		gWal.TruncateBefore(ts)
		log.Debug("sync data over!")
	}
}
func sync_data ( ) { ticker := time . Tick ( timeSeg ) for range ticker { log . Debug ( " " ) ts := wal . NewOffsetForTS ( time . Now ( ) . Add ( - 1 * timeSeg ) ) wr , err := gWal . NewReader ( " " , ts , gBytePool . Get ) if err != nil { log . Error ( err ) return } for { data , err := wr . Read ( ) if err != nil { log . Error ( err ) break } key , val , err := codec . ExtactKeyAndValue ( data ) if err != nil { log . Error ( " " , tools . BytesToStringFast ( data ) ) break } gKVClient . Set ( key , val ) } gWal . TruncateBefore ( ts ) log . Debug ( " " ) } }
sync data into low level db, cache remain one hour data
sync data into low level db cache remain one hour data