Google Datastore adapter for nsql-cache, enabling automatic caching of Datastore entities and queries. Version 1.1.6 integrates with nsql-cache (peer dependency ^1.1.4) to provide a managed LRU memory cache with configurable TTLs (default: 10 min for key fetches, 5 sec for queries). Key differentiators: transparent cache wrapping of the @google-cloud/datastore client, intelligent batch key fetching (only fetches missing keys from Datastore), and automatic cache invalidation on save/update/delete. Suitable for Node.js >=6.0, no TypeScript typings shipped. Released sporadically, last update 2018. Note: This adapter is also integrated into gstore-node.
npm install nsql-cache-datastoreNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initializes a Datastore client with environment-based credentials, wraps it with nsql-cache-datastore adapter, creates an NsqlCache instance, and fetches a User entity (automatically cached).
Use datastore.get() for key-based lookups to leverage caching. For queries, consider manual caching or use nsql-cache's query methods.
Test with latest @google-cloud/datastore; if issues arise, pin to an older version or migrate to gstore-node which includes the adapter.
Refer to nsql-cache documentation for per-request TTL and cache bypass options.
Use DatastoreAdapter(datastore) instead of new DatastoreAdapter(datastore).
const db = DatastoreAdapter(datastore);
npm install nsql-cache
Set GOOGLE_APPLICATION_CREDENTIALS environment variable or provide projectId in Datastore constructor.