Skip to content

Commit eaf0b90

Browse files
committed
cache optimization
1 parent 19e1143 commit eaf0b90

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

dist/index.browser.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11803,6 +11803,7 @@ function requirePatchTable () {
1180311803
}
1180411804

1180511805
async function patchTableCore(context, table, patches, { strategy = undefined, deduceStrategy = false, ...options } = {}, dryrun) {
11806+
console.dir(patches, {depth: Infinity});
1180611807
const engine = getSessionSingleton(context, 'engine');
1180711808
options = cleanOptions(options);
1180811809
strategy = JSON.parse(JSON.stringify(strategy || {}));
@@ -12129,6 +12130,10 @@ function requirePatchTable () {
1212912130

1213012131

1213112132
function createRowInCache({ context, table, key }) {
12133+
const tryGetFromCacheById = getOrCreateRow.tryGetFromCacheById || (getOrCreateRow.tryGetFromCacheById = requireTryGetFromCacheById());
12134+
const cachedRow = tryGetFromCacheById(context, table, ...key);
12135+
if (cachedRow)
12136+
return cachedRow;
1213212137
const newRow = getOrCreateRow.cachedNewRow || (getOrCreateRow.cachedNewRow = requireNewRow());
1213312138
const pkDto = {};
1213412139
for (let i = 0; i < key.length && i < table._primaryColumns.length; i++) {

dist/index.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11804,6 +11804,7 @@ function requirePatchTable () {
1180411804
}
1180511805

1180611806
async function patchTableCore(context, table, patches, { strategy = undefined, deduceStrategy = false, ...options } = {}, dryrun) {
11807+
console.dir(patches, {depth: Infinity});
1180711808
const engine = getSessionSingleton(context, 'engine');
1180811809
options = cleanOptions(options);
1180911810
strategy = JSON.parse(JSON.stringify(strategy || {}));
@@ -12130,6 +12131,10 @@ function requirePatchTable () {
1213012131

1213112132

1213212133
function createRowInCache({ context, table, key }) {
12134+
const tryGetFromCacheById = getOrCreateRow.tryGetFromCacheById || (getOrCreateRow.tryGetFromCacheById = requireTryGetFromCacheById());
12135+
const cachedRow = tryGetFromCacheById(context, table, ...key);
12136+
if (cachedRow)
12137+
return cachedRow;
1213312138
const newRow = getOrCreateRow.cachedNewRow || (getOrCreateRow.cachedNewRow = requireNewRow());
1213412139
const pkDto = {};
1213512140
for (let i = 0; i < key.length && i < table._primaryColumns.length; i++) {

src/patchTable.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ async function patchTable() {
1717
}
1818

1919
async function patchTableCore(context, table, patches, { strategy = undefined, deduceStrategy = false, ...options } = {}, dryrun) {
20+
console.dir(patches, {depth: Infinity});
2021
const engine = getSessionSingleton(context, 'engine');
2122
options = cleanOptions(options);
2223
strategy = JSON.parse(JSON.stringify(strategy || {}));
@@ -345,6 +346,10 @@ async function patchTableCore(context, table, patches, { strategy = undefined, d
345346

346347

347348
function createRowInCache({ context, table, key }) {
349+
const tryGetFromCacheById = getOrCreateRow.tryGetFromCacheById || (getOrCreateRow.tryGetFromCacheById = require('./table/tryGetFromCacheById'));
350+
const cachedRow = tryGetFromCacheById(context, table, ...key);
351+
if (cachedRow)
352+
return cachedRow;
348353
const newRow = getOrCreateRow.cachedNewRow || (getOrCreateRow.cachedNewRow = require('./table/commands/newRow'));
349354
const pkDto = {};
350355
for (let i = 0; i < key.length && i < table._primaryColumns.length; i++) {

0 commit comments

Comments
 (0)