MCPcopy
hub / github.com/grafana/dskit / TestMemcachedClient_Delete

Function TestMemcachedClient_Delete

cache/memcached_client_test.go:323–345  ·  cache/memcached_client_test.go::TestMemcachedClient_Delete
(t *testing.T)

Source from the content-addressed store, hash-verified

321}
322
323func TestMemcachedClient_Delete(t *testing.T) {
324 client, _, err := setupDefaultMemcachedClient()
325 require.NoError(t, err)
326
327 key := "foo"
328 value := []byte("bar")
329 expiration := 10 * time.Second
330
331 client.SetAsync(key, value, expiration)
332 require.NoError(t, client.wait())
333
334 // Verify that the key is initially present
335 initialResult := client.GetMulti(context.Background(), []string{key})
336 require.Equal(t, map[string][]byte{key: value}, initialResult)
337
338 // Delete operation
339 err = client.Delete(context.Background(), key)
340 require.NoError(t, err)
341
342 // Verify that the key is no longer present after deletion
343 afterDeletionResult := client.GetMulti(context.Background(), []string{key})
344 require.Empty(t, afterDeletionResult)
345}
346
347func TestMemcachedClient_Name(t *testing.T) {
348 client, _, err := setupDefaultMemcachedClient()

Callers

nothing calls this directly

Calls 6

waitMethod · 0.80
SetAsyncMethod · 0.65
GetMultiMethod · 0.65
DeleteMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected