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

Function TestMemcachedClient_SetAsync

cache/memcached_client_test.go:20–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func TestMemcachedClient_SetAsync(t *testing.T) {
21 t.Run("with non-zero TTL", func(t *testing.T) {
22 client, _, err := setupDefaultMemcachedClient()
23 require.NoError(t, err)
24 client.SetAsync("foo", []byte("bar"), 10*time.Second)
25 require.NoError(t, client.wait())
26
27 ctx := context.Background()
28 res := client.GetMulti(ctx, []string{"foo"})
29 require.Equal(t, map[string][]byte{"foo": []byte("bar")}, res)
30 })
31
32 t.Run("with truncated zero TTL", func(t *testing.T) {
33 client, _, err := setupDefaultMemcachedClient()
34 require.NoError(t, err)
35 client.SetAsync("foo", []byte("bar"), 100*time.Millisecond)
36 require.NoError(t, client.wait())
37
38 ctx := context.Background()
39 res := client.GetMulti(ctx, []string{"foo"})
40 require.Empty(t, res)
41 })
42
43 t.Run("with zero TTL", func(t *testing.T) {
44 client, _, err := setupDefaultMemcachedClient()
45 require.NoError(t, err)
46 client.SetAsync("foo", []byte("bar"), 0)
47 require.NoError(t, client.wait())
48
49 ctx := context.Background()
50 res := client.GetMulti(ctx, []string{"foo"})
51 require.Equal(t, map[string][]byte{"foo": []byte("bar")}, res)
52 })
53}
54
55func TestMemcachedClient_Set(t *testing.T) {
56 t.Run("with non-zero TTL", func(t *testing.T) {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected