MCPcopy Index your code
hub / github.com/apache/answer / Del

Method Del

plugin/kv_storage.go:214–236  ·  view source on GitHub ↗

Del removes values from KV storage by group and/or key. If both group and key are provided, only that specific entry is deleted. If only group is provided, all entries in that group are deleted. At least one of group or key must be provided.

(ctx context.Context, params KVParams)

Source from the content-addressed store, hash-verified

212// If only group is provided, all entries in that group are deleted.
213// At least one of group or key must be provided.
214func (kv *KVOperator) Del(ctx context.Context, params KVParams) error {
215 if params.Key == "" && params.Group == "" {
216 return ErrKVKeyAndGroupEmpty
217 }
218
219 kv.cleanCache(ctx, params)
220
221 session, cleanup := kv.getSession(ctx)
222 defer cleanup()
223
224 session.Where(builder.Eq{
225 "plugin_slug_name": kv.pluginSlugName,
226 })
227 if params.Group != "" {
228 session.Where(builder.Eq{"`group`": params.Group})
229 }
230 if params.Key != "" {
231 session.Where(builder.Eq{"`key`": params.Key})
232 }
233
234 _, err := session.Delete(&entity.PluginKVStorage{})
235 return err
236}
237
238// GetByGroup retrieves all key-value pairs for a specific group with pagination support.
239// Returns a map of keys to values or an error if the group is empty or not found.

Callers

nothing calls this directly

Calls 2

cleanCacheMethod · 0.95
getSessionMethod · 0.95

Tested by

no test coverage detected