diff --git a/pkg/tinykv/tinykv.go b/pkg/tinykv/tinykv.go index 25977af..fbc28c7 100644 --- a/pkg/tinykv/tinykv.go +++ b/pkg/tinykv/tinykv.go @@ -232,13 +232,11 @@ func (kv *store[T]) MarshalJSON() ([]byte, error) { func (e *entry[T]) MarshalJSON() ([]byte, error) { if e.timeout != nil { return json.Marshal(&struct { - Value T `json:"value"` - ExpiresAt time.Time `json:"expiresAt"` - ExpiresAfter time.Duration `json:"expiresAfter"` + Value T `json:"value"` + ExpiresAt time.Time `json:"expiresAt"` }{ - Value: e.value, - ExpiresAt: e.expiresAt, - ExpiresAfter: e.expiresAfter, + Value: e.value, + ExpiresAt: e.expiresAt, }) } else { return json.Marshal(&struct { diff --git a/pkg/tinykv/tinykv_test.go b/pkg/tinykv/tinykv_test.go index 90205e2..1c33613 100644 --- a/pkg/tinykv/tinykv_test.go +++ b/pkg/tinykv/tinykv_test.go @@ -115,7 +115,7 @@ func TestMarshalJSON(t *testing.T) { jsonb, err := json.Marshal(rg) assert.Nil(err) json := string(jsonb) - assert.Regexp(`{"1":{"value":1},"2":{"value":2},"3":{"value":3,"expiresAt":"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+Z","expiresAfter":3000000000000}}`, json) + assert.Regexp(`{"1":{"value":1},"2":{"value":2},"3":{"value":3,"expiresAt":"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d+Z"}}`, json) } func TestUnmarshalJSON(t *testing.T) { @@ -123,7 +123,7 @@ func TestUnmarshalJSON(t *testing.T) { in5Minutes := time.Now().Add(time.Minute * 5) in5MinutesJson, err := json.Marshal(in5Minutes) assert.Nil(err) - jsons := `{"1":{"value":1},"2":{"value":2},"3":{"value":3,"expiresAt":` + string(in5MinutesJson) + `,"expiresAfter":3000000000000}}` + jsons := `{"1":{"value":1},"2":{"value":2},"3":{"value":3,"expiresAt":` + string(in5MinutesJson) + `}}` rg := New[int](0) defer rg.Stop()