func (cch *store) newItemID() (itemID, error) {
	b := make([]byte, 8)
	l := big.NewInt(randSetLen)
	for i := 0; i < 8; i++ {
		n, err := rand.Int(rand.Reader, l)
		if err != nil {
			return "", err
		}
		b[i] = randSet[int(n.Int64())]
	}
	k := itemID(b)
	cch.mu.RLock()
	defer cch.mu.RUnlock()
	// Avoid overwriting existing entries
	if _, ok := cch.entries[k]; ok {
		return "", errors.New("cache: collision detected")
	}
	return k, nil
}
// newItemID creates a new store key, ensuring it is unique.
newItemID creates a new store key, ensuring it is unique.
// newItemID creates a new store key ensuring it is unique .
func (cch *store) newItemID() (itemID, error) {
	b := make([]byte, 8)
	l := big.NewInt(randSetLen)
	for i := 0; i < 8; i++ {
		n, err := rand.Int(rand.Reader, l)
		if err != nil {
			return "", err
		}
		b[i] = randSet[int(n.Int64())]
	}
	k := itemID(b)
	cch.mu.RLock()
	defer cch.mu.RUnlock()
	if _, ok := cch.entries[k]; ok {
		return "", errors.New("cache: collision detected")
	}
	return k, nil
}
func ( cch * store ) newItemID ( ) ( itemID , error ) { b := make ( [ ] byte , 8 ) l := big . NewInt ( randSetLen ) for i := 0 ; i < 8 ; i ++ { n , err := rand . Int ( rand . Reader , l ) if err != nil { return " " , err } b [ i ] = randSet [ int ( n . Int64 ( ) ) ] } k := itemID ( b ) cch . mu . RLock ( ) defer cch . mu . RUnlock ( ) if _ , ok := cch . entries [ k ] ; ok { return " " , errors . New ( " " ) } return k , nil }
newItemID creates a new store key, ensuring it is unique.
newItemID creates a new store key ensuring it is unique .
// Avoid overwriting existing entries