Skip to content

mnaoumov/obsidian-backlink-cache

Repository files navigation

Backlink Cache

This is a plugin for Obsidian that maintains backlink cache to speed up undocumented app.metadataCache.getBacklinksForFile function.

It's mostly useful for users with the large vaults. On smaller vaults the difference might be unnoticeable.

It speeds up Backlinks Pane performance and plugins that deal with the backlinks.

This plugin the most likely will be useful for other plugin developers that deal with the backlinks.

Its idea came from the forum.

Usage

Fast version

The provided version is faster than the built-in version. Also the overload to accept path was added.

const backlinks1 = app.metadataCache.getBacklinksForFile(file);
const backlinks2 = app.metadataCache.getBacklinksForFile(path);

Safe version

If you want to ensure the all recent file changes are processed and the backlinks are 100% accurate.

const backlinks1 = await app.metadataCache.getBacklinksForFile.safe(file);
const backlinks2 = await app.metadataCache.getBacklinksForFile.safe(path);

Original version

You can access the original built-in version:

const backlinks = app.metadataCache.getBacklinksForFile.originalFn(file);

Installation

Support

Buy Me A Coffee

License

© Michael Naumov