Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "axiodb",
"version": "6.33.228",
"version": "6.33.229",
"description": "The Pure JavaScript Alternative to SQLite. Embedded NoSQL database for Node.js with MongoDB-style queries, zero native dependencies, built-in InMemoryCache, and web GUI. Perfect for desktop apps, CLI tools, and embedded systems. No compilation, no platform issues—pure JavaScript from npm install to production.",
"main": "./lib/config/DB.js",
"types": "./lib/config/DB.d.ts",
Expand Down
8 changes: 6 additions & 2 deletions source/Services/Collection/collection.operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Converter from "../../Helper/Converter.helper";
import FolderManager from "../../engine/Filesystem/FolderManager";
import InsertIndex from "../Index/InsertIndex.service";
import { IndexCache } from "../Index/IndexCache.service";
import InMemoryCache from "../../Memory/memory.operation";

/**
* Represents a collection inside a database.
Expand Down Expand Up @@ -186,10 +187,13 @@ export default class Collection {

// Save the data first
const saveResult = await this.Insertion.Save(data, documentId);

// Index insertion after save
await this.IndexManager.InsertToIndex(data);


// Fire-and-forget: Invalidate cache asynchronously for faster response
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says "Invalidate cache asynchronously for faster response", but invalidateByDocument() / invalidateByCollection() currently contain no await, so the invalidation work runs synchronously when called. Either adjust the comment to match reality, or explicitly defer the invalidation (with a clear note about any potential staleness tradeoff).

Suggested change
// Fire-and-forget: Invalidate cache asynchronously for faster response
// Invalidate cache without awaiting the returned Promise; errors are intentionally ignored

Copilot uses AI. Check for mistakes.
InMemoryCache.invalidateByDocument(this.path, documentId).catch(() => {});
Comment on lines +194 to +195
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new cache invalidation in insert() is untested. Since reads are cached in Reader.exec() via InMemoryCache.getCache/setCache, add a regression test that (1) runs a query to populate cache, (2) inserts a new document, and (3) re-runs the same query and asserts the new document appears (i.e., cached results were invalidated).

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

insertMany() calls insert() in a loop; with this change, cache invalidation will run once per inserted document. Consider adding a way to batch/skip per-document invalidation during bulk inserts and invalidate the collection cache once at the end to avoid repeated full-map scans when the cache is populated.

Copilot uses AI. Check for mistakes.

return saveResult;
}

Expand Down
Loading