Key-Value Store
Key-value stores are the simplest type of NoSQL database and store pieces of data as two common elements: a unique key for identification and the value that is captured. Keys can be used by applications to perform lookup operations to retrieve the data values that are associated with them. These data stores are highly scalable, distributing data across all available storage by applying a hash algorithm to the keys. While keys are unique and scalar, values can range from scalar values to complex data objects such as JSON arrays. Figure 3.1 is an example of a key-value store that stores phone directory data.
FIGURE 3.1 Key-Value store
Key-value stores are optimized for ingesting large volumes of data that must be stored and read very quickly. Applications reading data from key-value stores typically perform simple lookups using a single key or a range of keys. Here are two common scenarios where key-value stores are ideal storage solutions:
- Web applications that store user session metadata in real time. These applications can also use key-value stores to make real-time recommendations to users as they are browsing the site.
- Caching frequently accessed data to optimize application performance by minimizing reads to disk-based storage such as Azure SQL Database.
While key-value stores are great at serving data to applications performing simple read operations, they are not ideal storage solutions for applications that need to perform intense search operations. They also do not support scenarios where queries need to filter data by the values. Key-value stores also only support insert and delete operations, requiring users to modify data by completely overwriting existing items.
Azure provides a few different options for implementing a key-value store:
- Azure Table storage
- Azure Cosmos DB Table API
- Azure Cache for Redis
This chapter will focus on Azure Table storage and the Azure Cosmos DB Table API as these are in scope for the DP-900 exam. You can find more information at https://docs.microsoft.com/en-us/azure/azure-cache-for-redis/cache-overview if you would like to learn more about Azure Cache for Redis.