func testPutTTL(t *testing.T, kv store.Store, otherConn store.Store) { firstKey := "first" firstValue := []byte("foo") secondKey := "second" secondValue := []byte("bar") // Put the first key with the Ephemeral flag err := otherConn.Put(firstKey, firstValue, &store.WriteOptions{TTL: 2 * time.Second}) assert.NoError(t, err) // Put a second key with the Ephemeral flag err = otherConn.Put(secondKey, secondValue, &store.WriteOptions{TTL: 2 * time.Second}) assert.NoError(t, err) // Get on firstKey should work pair, err := kv.Get(firstKey) assert.NoError(t, err) assert.NotNil(t, pair) // Get on secondKey should work pair, err = kv.Get(secondKey) assert.NoError(t, err) assert.NotNil(t, pair) // Close the connection otherConn.Close() // Let the session expire time.Sleep(3 * time.Second) // Get on firstKey shouldn't work pair, err = kv.Get(firstKey) assert.Error(t, err) assert.Nil(t, pair) // Get on secondKey shouldn't work pair, err = kv.Get(secondKey) assert.Error(t, err) assert.Nil(t, pair) }