Design a Generic, Type-Safe Key-Value Store API
Context
You're asked to design a reusable key-value store with a generic, user-friendly API suitable for local in-memory use and evolvable to persistent storage. Assume Java for the typed API, but design decisions should be language-agnostic where possible.
Requirements
-
Define the data model and core operations:
-
put, get, delete, exists, batch
-
Expose generics in the interface (e.g., Java), while maintaining type safety.
-
Design for reusability and layering (e.g., pluggable serialization and storage engines).
-
Describe error handling strategy.
-
Discuss versioning and TTL options (optimistic concurrency control, expirations).
-
Outline how to evolve an in-memory prototype into a persistent implementation.