-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #426 from HarperDB/aakers/cache-table-data
Caching Describe Table Call, Reducing Expensive Call To Backend
- Loading branch information
Showing
6 changed files
with
68 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const descriptionCache = new Map(); | ||
|
||
const getTableKey = (schema, table) => `${schema}/${table}`; | ||
|
||
const getTableDescriptionFromCache = (schema, table) => { | ||
const tableKey = getTableKey(schema, table); | ||
return descriptionCache.get(tableKey) ?? undefined; | ||
}; | ||
|
||
const setTableDescriptionInCache = (schema, table, description) => { | ||
const tableKey = getTableKey(schema, table); | ||
descriptionCache.set(tableKey, description); | ||
}; | ||
|
||
const clearTableDescriptionCache = () => { | ||
if (!descriptionCache.size) return; | ||
descriptionCache.clear(); | ||
}; | ||
|
||
export { descriptionCache, getTableDescriptionFromCache, setTableDescriptionInCache, clearTableDescriptionCache }; |