// DelKeyWithPrefix deletes keys with prefix.
192220
func DelKeyWithPrefix(rm kv.RetrieverMutator, prefix kv.Key) error {
	var keys []kv.Key
	iter, err := rm.Iter(prefix, prefix.PrefixNext())
	if err != nil {
		return errors.Trace(err)
	}

	defer iter.Close()
	for {
		if err != nil {
			return errors.Trace(err)
		}

		if iter.Valid() && iter.Key().HasPrefix(prefix) {
			keys = append(keys, iter.Key().Clone())
			err = iter.Next()
			if err != nil {
				return errors.Trace(err)
			}
		} else {
			break
		}
	}

	for _, key := range keys {
		err := rm.Delete(key)
		if err != nil {
			return errors.Trace(err)
		}
	}

	return nil
}
521363
func (aSpace *addrSpace) KeyPrefix() []string {
	aSpace.Lock()
	defer aSpace.Unlock()
	return []string{dsConfigKey}
}
879270
func (m *ExpirationManager) RevokePrefix(ctx context.Context, prefix string, sync bool) error {
	defer metrics.MeasureSince([]string{"expire", "revoke-prefix"}, time.Now())

	return m.revokePrefixCommon(ctx, prefix, false, sync)
}
679770
func WithPrefix(p string) source.Option {
	return func(o *source.Options) {
		if o.Context == nil {
			o.Context = context.Background()
		}
		o.Context = context.WithValue(o.Context, prefixKey{}, p)
	}
}
334762
func (eng *Engine) WithPrefix(prefix string, tags ...Tag) *Engine {
	return &Engine{
		Handler: eng.Handler,
		Prefix:  eng.makeName(prefix),
		Tags:    eng.makeTags(tags),
	}
}
843255
func (s *DescribeMLModelsInput) SetPrefix(v string) *DescribeMLModelsInput {
	s.Prefix = &v
	return s
}
749072
func InjectWithPrefix(funcs map[string]interface{}, prefix string) {
	for k, v := range GtfFuncMap {
		funcs[prefix+k] = v
	}
}
488810
func (s *MetricsFilter) SetPrefix(v string) *MetricsFilter {
	s.Prefix = &v
	return s
}
1297004
func (s *S3ResourceClassification) SetPrefix(v string) *S3ResourceClassification {
	s.Prefix = &v
	return s
}
213127
func (p *PathManager) RemovePathPrefix(prefix string) {
	p.l.Lock()
	defer p.l.Unlock()

	// We trim any trailing *, but we don't touch whether it is a trailing
	// slash or not since we want to be able to ignore prefixes that fully
	// specify a file
	p.paths, _ = p.paths.DeletePrefix([]byte(strings.TrimSuffix(prefix, "*")))
}
603843
func (s *ReplicationRule) SetPrefix(v string) *ReplicationRule {
	s.Prefix = &v
	return s
}
185500
func (t *Txn) DeletePrefix(prefix []byte) bool {
	newRoot, numDeletions := t.deletePrefix(nil, t.root, prefix)
	if newRoot != nil {
		t.root = newRoot
		t.size = t.size - numDeletions
		return true
	}
	return false

}
555644
func WithPrefix(prefix string) option {
	return func(m *Module) {
		m.prefix = strings.ToLower(prefix)
	}
}
162709
func AddPrefix(path string) string {
	if !strings.HasPrefix(path, Prefix) {
		path = Prefix + path
	}
	return path
}
300590
func WithPrefixMask(mask idpool.ID) AllocatorOption {
	return func(a *Allocator) { a.prefixMask = mask }
}
67933
func (c *Conn) MatchPrefix(key string, maxrecords int64) ([]string, error) {
	keystransmit := []KV{
		{"prefix", []byte(key)},
		{"max", []byte(strconv.FormatInt(maxrecords, 10))},
	}
	code, m, err := c.doRPC("/rpc/match_prefix", keystransmit)
	if err != nil {
		return nil, err
	}
	if code != 200 {
		return nil, makeError(m)
	}
	res := make([]string, 0, len(m))
	for _, kv := range m {
		if kv.Key[0] == '_' {
			res = append(res, string(kv.Key[1:]))
		}
	}
	if len(res) == 0 {
		// yeah, gokabinet was weird here.
		return nil, ErrSuccess
	}
	return res, nil
}
447903
func (kf *KeyFormat) KeyNoPrefix(args ...interface{}) (Prefix, error) {
	key, err := kf.Key(args...)
	if err != nil {
		return nil, err
	}
	return key[len(kf.prefix):], nil
}