func (s *Scanner) Value() []byte {
	if s.valid {
		return s.cache[s.idx].Value
	}
	return nil
}
Value return value.
package txnsnapshot
import (
	"bytes"
	"context"
	"github.com/pingcap/errors"
	"github.com/pingcap/kvproto/pkg/kvrpcpb"
	tikverr "github.com/tikv/client-go/v2/error"
	"github.com/tikv/client-go/v2/internal/client"
	"github.com/tikv/client-go/v2/internal/locate"
	"github.com/tikv/client-go/v2/internal/logutil"
	"github.com/tikv/client-go/v2/internal/retry"
	"github.com/tikv/client-go/v2/kv"
	"github.com/tikv/client-go/v2/tikvrpc"
	"github.com/tikv/client-go/v2/txnkv/txnlock"
	"go.uber.org/zap"
)
type Scanner struct {
	snapshot     *KVSnapshot
	batchSize    int
	cache        []*kvrpcpb.KvPair
	idx          int
	nextStartKey []byte
	endKey       []byte
	nextEndKey []byte
	reverse    bool
	valid bool
	eof   bool
}
func newScanner(snapshot *KVSnapshot, startKey []byte, endKey []byte, batchSize int, reverse bool) (*Scanner, error) {
	if batchSize <= 1 {
		batchSize = defaultScanBatchSize
	}
	scanner := &Scanner{
		snapshot:     snapshot,
		batchSize:    batchSize,
		valid:        true,
		nextStartKey: startKey,
		endKey:       endKey,
		reverse:      reverse,
		nextEndKey:   endKey,
	}
	err := scanner.Next()
	if tikverr.IsErrNotFound(err) {
		return scanner, nil
	}
	return scanner, err
}
func (s *Scanner) Valid() bool {
	return s.valid
}
func (s *Scanner) Key() []byte {
	if s.valid {
		return s.cache[s.idx].Key
	}
	return nil
}