Read-after-write consistency for derived non-relational data
Abstract
A system is provided that ensures read-after-write consistency. During operation, the system receives, from a user, a write to a record having a primary key in a master key-value store, wherein the write specifies a secondary key for the record. The system then caches the secondary key and the primary key in a cache entry in a cache, wherein the cache entry is associated with the user. Next, the system applies the write to the master key-value store. Prior to propagation of the write from the master key-value store to a derived key-value store that maps secondary keys to primary keys, the system receives from a given user a query for the record, the query comprising the secondary key and not the primary key. Next the system translates the secondary key to the primary key by querying the cache when the given user is the user.
Claims
exact text as granted — not AI-modifiedWhat is claimed is:
1 . A method, comprising:
receiving, from a first user, a write to a first record having a first primary key in a master key-value store, wherein the write specifies a first secondary key for the first record; caching the first secondary key and the first primary key in a first cache entry in a cache, wherein the first cache entry is associated with the first user; applying the write to the master key-value store; prior to propagation of the write from the master key-value store to a derived key-value store that maps secondary keys to primary keys, receiving from a given user a query for the first record, the query comprising the first secondary key and not the first primary key; and translating the first secondary key to the first primary key by:
when the given user is the first user, querying the cache; and
when the given user is not the first user, querying the derived key-value store.
2 . The method of claim 1 , wherein associating the first cache entry with the first user comprises:
extracting from the write a first identifier of the first user; and including the first identifier in the first cache entry.
3 . The method of claim 2 , wherein said translating comprises:
extracting from the query a given identifier of the given user; determining whether the cache layer includes an entry comprising the given identifier; and when the cache layer includes an entry comprising the given identifier:
determining whether the cache entry comprises the first secondary key; and
when the secondary key of the cache entry comprises the first secondary key, retrieving the primary key of the cache entry.
4 . The method of claim 1 , wherein applying the write to the master key-value store comprises one of:
replacing an existing secondary key of the first record with the first secondary key; and creating the first record with the first secondary key and associating the first record with the first primary key in the master key-value store.
5 . The method of claim 1 , further comprising, subsequent to the application of the write to the master key-value store but prior to the propagation of the write to the derived key-value store:
receiving from a second user a second query for the first record, the second query comprising the first secondary key and not the first primary key; determining that no cache entry in the cache that comprises the secondary key is associated with the second user; and attempting to translate the first secondary key to the first primary key at the derived key-value store, wherein the first secondary key is not found in the derived key-value store.
6 . The method of claim 1 , wherein:
the master key-value store and the derived key-value store are Espresso tables; each record is an Espresso document; and one or more Databus change events propagate the write to the derived key-value store.
7 . The method of claim 1 , wherein:
each record in the master key-value store corresponds to a company; and the secondary key corresponds to one of:
a universal name of the company;
an email domain of the company; and
a stock symbol of the company.
8 . The method of claim 1 , further comprising, retrieving the first record from the master key-value store with the first primary key and returning the first record to the first user.
9 . An apparatus, comprising:
one or more processors; and memory storing instructions that, when executed by the one or more processors, cause the apparatus to:
receive, from a first user, a write to a first record having a first primary key in a master key-value store, wherein the write specifies a first secondary key for the first record;
cache the first secondary key and the first primary key in a first cache entry in a cache, wherein the first cache entry is associated with the first user;
apply the write to the master key-value store;
prior to propagation of the write from the master key-value store to a derived key-value store that maps secondary keys to primary keys, receive from a given user a query for the first record, the query comprising the first secondary key and not the first primary key; and
translate the first secondary key to the first primary key by:
when the given user is the first user, querying the cache; and
when the given user is not the first user, querying the derived key-value store.
10 . The apparatus of claim 9 , wherein associating the first cache entry with the first user comprises:
extracting from the write a first identifier of the first user; and including the first identifier in the first cache entry.
11 . The apparatus of claim 10 , wherein said translating comprises:
extracting from the query a given identifier of the given user; determining whether the cache layer includes an entry comprising the given identifier; and when the cache layer includes an entry comprising the given identifier:
determining whether the cache entry comprises the first secondary key; and
when the secondary key of the cache entry comprises the first secondary key, retrieving the primary key of the cache entry.
12 . The apparatus of claim 9 , wherein applying the write to the master key-value store comprises one of:
replacing an existing secondary key of the first record with the first secondary key; and creating the first record with the first secondary key and associating the first record with the first primary key in the master key-value store.
13 . The apparatus of claim 9 , wherein subsequent to the application of the write to the master key-value store but prior to the propagation of the write to the derived key-value store, the apparatus is further caused to:
receive from a second user a second query for the first record, the second query comprising the first secondary key and not the first primary key; determine that no cache entry in the cache that comprises the secondary key is associated with the second user; and attempt to translate the first secondary key to the first primary key at the derived key-value store, wherein the first secondary key is not found in the derived key-value store.
14 . The apparatus of claim 9 , wherein:
the master key-value store and the derived key-value store are Espresso tables; each record is an Espresso document; and one or more Databus change events propagate the write to the derived key-value store.
15 . The apparatus of claim 9 , wherein:
each record in the master key-value store corresponds to a company; and the secondary key corresponds to one of:
a universal name of the company;
an email domain of the company; and
a stock symbol of the company.
16 . The apparatus of claim 9 , wherein the apparatus is further caused to retrieve the first record from the master key-value store with the first primary key and returning the first record to the first user.
17 . A system, comprising:
one or more processors; an database module comprising a non-transitory computer-readable medium storing instructions that, when executed, cause the system to:
receive, from a first user, a write to a first record having a first primary key in a master key-value store, wherein the write specifies a first secondary key for the first record;
cache the first secondary key and the first primary key in a first cache entry in a cache, wherein the first cache entry is associated with the first user;
apply the write to the master key-value store;
prior to propagation of the write from the master key-value store to a derived key-value store that maps secondary keys to primary keys, receive from a given user a query for the first record, the query comprising the first secondary key and not the first primary key; and
translate the first secondary key to the first primary key by:
when the given user is the first user, querying the cache; and
when the given user is not the first user, querying the derived key-value store.
18 . The system of claim 17 , wherein associating the first cache entry with the first user comprises:
extracting from the write a first identifier of the first user; and including the first identifier in the first cache entry.
19 . The system of claim 17 , wherein said translating comprises:
extracting from the query a given identifier of the given user; determining whether the cache layer includes an entry comprising the given identifier; and when the cache layer includes an entry comprising the given identifier:
determining whether the cache entry comprises the first secondary key; and
when the secondary key of the cache entry comprises the first secondary key, retrieving the primary key of the cache entry.
20 . The system of claim 17 , wherein applying the write to the master key-value store comprises one of:
replacing an existing secondary key of the first record with the first secondary key; and creating the first record with the first secondary key and associating the first record with the first primary key in the master key-value store.Join the waitlist — get patent alerts
Track US2017316045A1 — get alerts on status changes and closely related new filings.
We store only your email — no account needed. See our privacy policy.