IP Library Granted Patent US 11,650,984
Granted Patent B2
US 11,650,984 · App. 17/387,303 · Granted May 16, 2023

Using a caching layer for key-value storage in a database

Inventors: Mark Nelson (Minnetonka, MN); Gabriel Zvi BenHanokh (Tel-Aviv, IL)
Assignee: RED HAT, INC.
G06F16/24552G06F12/123G06F16/214G06F16/2282G06F2212/1021
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,650,984
App. No.
17/387,303
Granted
May 16, 2023
Kind
B2
Abstract

A technique for using a caching layer for key-value storage in a database is described. In one example of the present disclosure, a system can receive, at an unsorted data structure of a caching layer, a key-value pair associated with a data object. The unsorted data structure can store a first plurality of key-value pairs. The system can receive one or more operations for updating the key-value pair in the caching layer. The system can determine the key-value pair is to be migrated to a sorted memory table based on a caching algorithm. The system can migrate the key-value pair to a sorted memory table configured to store a second plurality of key-value pairs that is larger than the first plurality of key-value pairs and sort the key-value pair with the second plurality of key-value pairs prior to storing the key-value pair in the sorted memory table.

Claims (65)

1. A system comprising:

a processor; and

a memory device including instructions that are executable by the processor for causing the processor to:

receive, at an unsorted data structure of a caching layer, a key-value pair associated with a data object, the unsorted data structure storing a first plurality of key-value pairs;

receive one or more operations for updating the key-value pair in the caching layer;

determine, with the caching layer being full and an additional key-value pair being received to be stored in the caching layer, the key-value pair is to be migrated to a sorted memory table based on a caching algorithm;

migrate the key-value pair to the sorted memory table configured to store a second plurality of key-value pairs that is larger than the first plurality of key-value pairs, a size of the caching layer being adjustable based on a number of the second plurality of key-value pairs that receive operations; and

sort the key-value pair with the second plurality of key-value pairs prior to storing the key-value pair in the sorted memory table.

2. The system of claim 1 , wherein the memory device further includes instructions that are executable by the processor for causing the processor to:

determine the sorted memory table stores the second plurality of key-value pairs; and

migrate the second plurality of key-value pairs from the sorted memory table and the first plurality of key-value pairs from the unsorted data structure to a disk storage device.

3. The system of claim 2 , wherein the memory device further includes instructions that are executable by the processor for causing the processor to migrate the second plurality of key-value pairs and the first plurality of key-value pairs to the disk storage device by:

sorting the first plurality of key-value pairs from the unsorted data structure to generate a first sorted list of key-value pairs;

receiving a second sorted list of key-value pairs for the second plurality of key-value pairs from the sorted memory table;

merging the first sorted list and the second sorted list to generate a third sorted list of key-value pairs that includes the first plurality of key-value pairs and the second value of key-value pairs; and

storing the third sorted list of key-value pairs in the disk storage device.

4. The system of claim 1 , wherein each key-value pair of the second plurality of key-value pairs has been previously stored in the unsorted data structure prior to being stored in the sorted memory table.

5. The system of claim 1 , wherein the memory device further includes instructions that are executable by the processor for causing the processor to:

determine a cache hit ratio associated with the first plurality of key-value pairs is below a threshold; and

in response to determining the cache hit ratio is below the threshold, disable the caching layer so that subsequent key-value pairs are received by the sorted memory table without previously being stored in the caching layer.

6. The system of claim 1 , wherein the memory device further includes instructions that are executable by the processor for causing the processor to:

determine the number of the second plurality of key-value pairs that receive operations exceeds a threshold; and

in response to determining the number of the second plurality of key-value pairs that receive operations exceeds the threshold, change a size of the unsorted data structure to store the first plurality of key-value pairs and the number of the second plurality of key-value pairs that receive the operations.

7. The system of claim 1 , wherein a size of the unsorted data structure is static.

8. A method comprising:

storing a first plurality of key-value pairs in an unsorted caching layer of a database equal to a number of key-value pairs the unsorted caching layer is configured to store;

receiving an additional key-value pair at the unsorted caching layer;

determining a key-value pair of the first plurality of key-value pairs that has been least-recently added to the unsorted caching layer;

migrating the key-value pair to a sorted memory table of the database, the sorted memory table configured to store a second plurality of key-value pairs of a higher number than the unsorted caching layer, a size of the caching layer being adjustable based on a number of the second plurality of key-value pairs that receive operations; and

subsequent to migrating the key-value pair to the sorted memory table, storing the additional key-value pair in the unsorted caching layer.

9. The method of claim 8 , further comprising:

determining the sorted memory table is full; and

migrating the second plurality of key-value pairs in the sorted memory table and the first plurality of key-value pairs in the unsorted caching layer to a disk storage device.

10. The method of claim 9 , wherein migrating the second plurality of key-value pairs and the first plurality of key-value pairs to the disk storage device comprises:

sorting the first plurality of key-value pairs from the unsorted caching layer to generate a first sorted list of key-value pairs;

receiving a second sorted list of key-value pairs for the second plurality of key-value pairs from the sorted memory table;

merging the first sorted list and the second sorted list to generate a third sorted list of key-value pairs that includes the first plurality of key-value pairs and the second value of key-value pairs; and

storing the third sorted list of key-value pairs in the disk storage device.

11. The method of claim 8 , wherein each key-value pair of the second plurality of key-value pairs has been previously stored in the unsorted caching layer prior to being stored in the sorted memory table.

12. The method of claim 8 , further comprising:

determining a cache-hit ratio associated with the first plurality of key-value pairs is below a threshold; and

in response to determining the cache hit ratio is below the threshold, disabling the unsorted caching layer so that subsequent key-value pairs are received by the sorted memory table without previously being stored in the unsorted caching layer.

13. The method of claim 8 , further comprising:

determining the number of the second plurality of key-value pairs that receive operations exceeds a threshold; and

in response to determining the number of the second plurality of key-value pairs that receive operations exceeds the threshold, changing a size of the unsorted caching layer to store the first plurality of key-value pairs and the number of the second plurality of key-value pairs that receive the operations.

14. A non-transitory computer-readable medium comprising program code executable by a processor for causing the processor to:

receive, at a disk storage device of a database, a first plurality of key-value pairs from a caching layer of the database and a second plurality of key-value pairs from a memory table of the database, the first plurality of key-value pairs being unsorted in the caching layer and the second plurality of key-value pairs being sorted in the memory table, and each key-value pair of the second plurality of key-value pairs previously being stored in the caching layer prior to being stored in the memory table, a size of the caching layer being adjustable based on a number of the second plurality of key-value pairs that receive operations;

sort the first plurality of key-value pairs with the second plurality of key-value pairs; and

store the first plurality of key-value pairs and the second plurality of key-value pairs sorted in the disk storage device.

15. The non-transitory computer-readable medium of claim 14 , further comprising program code that is executable by the processor for causing the processor to sort the first plurality of key-value pairs with the second plurality of key-value pairs by:

sorting the first plurality of key-value pairs from the caching layer to generate a first sorted list of key-value pairs;

receiving a second sorted list of key-value pairs for the second plurality of key-value pairs from the memory table;

merging the first sorted list and the second sorted list to generate a third sorted list of key-value pairs that includes the first plurality of key-value pairs and the second value of key-value pairs; and

storing the third sorted list of key-value pairs in the disk storage device.

16. The non-transitory computer-readable medium of claim 14 , further comprising program code that is executable by the processor for causing the processor to:

determine a cache-hit ratio associated with the first plurality of key-value pairs is below a threshold; and

in response to determining the cache hit ratio is below the threshold, disable the caching layer so that subsequent key-value pairs are received by the memory table without previously being stored in the caching layer.

17. The non-transitory computer-readable medium of claim 14 , further comprising program code that is executable by the processor for causing the processor to:

determine the number of the second plurality of key-value pairs that receive operations exceeds a threshold; and

in response to determining the number of the second plurality of key-value pairs that receive operations exceeds the threshold, change a size of the caching layer to store the first plurality of key-value pairs and the number of the second plurality of key-value pairs that receive the operations.

18. The non-transitory computer-readable medium of claim 14 , further comprising program code that is executable by the processor for causing the processor to:

determine a key-value pair of the first plurality of key-value pairs is to be migrated based on a caching algorithm; and

migrate the key-value pair to the memory table by sorting the key-value pair with the second plurality of key-value pairs.

19. The non-transitory computer-readable medium of claim 14 , wherein the disk storage device receives the first plurality of key-value pairs and the second plurality of key-value pairs in response to the memory table being full.

20. The non-transitory computer-readable medium of claim 14 , wherein a size of the caching layer is static.

Assignments (2)
CHANGE OF NAME Recorded Mar 3, 2026
From: RED HAT, INC.
To: RED HAT, LLC
Reel/Frame 074913/0759 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jul 28, 2021
From: NELSON, MARK; BENHANOKH, GABRIEL ZVI
To: RED HAT, INC.
Reel/Frame 057006/0796 →
Continuity (1)
Related Publication 20230032841A1 · Feb 2, 2023