@stephen-shopopop/cache
    Preparing search index...

    Class SQLiteConnector

    SQLiteConnector implements a singleton pattern for SQLite database connections. This class manages database connections and ensures only one instance exists for the cache.

    The singleton is exposed to allow advanced developers to perform direct reads, diagnostics, or custom actions on the underlying SQLite database, while ensuring only one connection exists.

    Warning:

    • Any direct use of the singleton must respect the single-connection policy (no parallel connections).
    • Custom queries or writes may impact the cache's integrity or performance.
    • Use with caution and always document your advanced usages in your codebase.

    This design follows the SOLID Open/Closed principle: the cache is extensible for advanced needs without modifying its core logic, but remains safe for standard usage.

    SQLiteConnector

    // Access the singleton for advanced operations (read-only or diagnostics)
    const connector = SQLiteConnector.getInstance(':memory:');
    const db = connector.createConnection();
    // ...custom queries...

    If the SQLite database connection cannot be established

    Index

    Methods

    • Creates a synchronous SQLite database connection.

      Returns DatabaseSync

      A new instance of DatabaseSync connected to the specified path

      If the database connection cannot be established

    • Returns a singleton instance of SQLiteConnector. If an instance doesn't exist, creates one with the given parameters.

      Parameters

      • path: Path = ':memory:'

        The path to the SQLite database file. Defaults to ':memory:' for in-memory database.

      • Optionaltimeout: number

        Optional timeout value in milliseconds

      Returns SQLiteConnector

      The singleton SQLiteConnector instance

      const connector = SQLiteConnector.getInstance('/path/to/db', 5000);