{"id":45616,"library":"nsql-cache-datastore","title":"nsql-cache-datastore","description":"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.","status":"active","version":"1.1.6","language":"javascript","source_language":"en","source_url":"https://github.com/sebelga/nsql-cache-datastore","tags":["javascript"],"install":[{"cmd":"npm install nsql-cache-datastore","lang":"bash","label":"npm"},{"cmd":"yarn add nsql-cache-datastore","lang":"bash","label":"yarn"},{"cmd":"pnpm add nsql-cache-datastore","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency – provides the caching logic that this adapter plugs into.","package":"nsql-cache","optional":false}],"imports":[{"note":"Package does not ship ESM or types; use CommonJS require. The default export is a function that takes a Datastore instance.","wrong":"import DatastoreAdapter from 'nsql-cache-datastore';","symbol":"DatastoreAdapter","correct":"const DatastoreAdapter = require('nsql-cache-datastore');"},{"note":"Function is exported as module.exports = DatastoreAdapter. No named exports available.","wrong":null,"symbol":"default","correct":"const DatastoreAdapter = require('nsql-cache-datastore');"},{"note":"nsql-cache also uses CommonJS; the class is the default export.","wrong":"import { NsqlCache } from 'nsql-cache';","symbol":"nsql-cache (NsqlCache)","correct":"const NsqlCache = require('nsql-cache');"}],"quickstart":{"code":"const Datastore = require('@google-cloud/datastore');\nconst NsqlCache = require('nsql-cache');\nconst DatastoreAdapter = require('nsql-cache-datastore');\n\nconst datastore = new Datastore({\n  projectId: process.env.GCLOUD_PROJECT ?? '',\n  keyFilename: process.env.GOOGLE_APPLICATION_CREDENTIALS ?? '',\n});\nconst db = DatastoreAdapter(datastore);\nconst cache = new NsqlCache({ db });\n\nasync function getUser(id) {\n  const key = datastore.key(['User', id]);\n  return datastore.get(key);\n}\n\ngetUser(1).then(console.log).catch(console.error);","lang":"javascript","description":"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)."},"warnings":[{"fix":"Use datastore.get() for key-based lookups to leverage caching. For queries, consider manual caching or use nsql-cache's query methods.","message":"The adapter only wraps @google-cloud/datastore methods: get, save, update, insert, upsert, delete. Other Datastore methods (e.g., runQuery, createQuery) are not cached.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Test with latest @google-cloud/datastore; if issues arise, pin to an older version or migrate to gstore-node which includes the adapter.","message":"The @google-cloud/datastore package has been deprecated in favor of @google-cloud/datastore v2+. Check compatibility with newer Datastore client versions.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Refer to nsql-cache documentation for per-request TTL and cache bypass options.","message":"Cache TTLs are global defaults; individual request-level overrides require passing options to the Datastore methods (e.g., datastore.get(key, { ttl: 60000 })).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use DatastoreAdapter(datastore) instead of new DatastoreAdapter(datastore).","message":"Version 1.0.0 changed the export from a constructor to a factory function. Older code using 'new DatastoreAdapter()' will break.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'/datastore':60 '1.1.4':29 '1.1.6':21 '10':41 '2018':90 '5':46 '6.0':81 'adapt':7,93 'also':95 'automat':13,73 'batch':63 'cach':3,11,14,26,36,53,74 'client':61 'cloud':59 'configur':38 'datastor':4,6,16,71 'default':40 'depend':28 'differenti':51 'enabl':12 'entiti':17 'fetch':45,65,67 'googl':5,58 'google-cloud':57 'gstore':99 'gstore-nod':98 'integr':22,96 'intellig':62 'invalid':75 'javascript':101 'key':44,50,64,69 'last':88 'lru':34 'manag':33 'memori':35 'min':42 'miss':68 'node':100 'node.js':80 'note':91 'nsql':2,10,25 'nsql-cach':9,24 'nsql-cache-datastor':1 'peer':27 'provid':31 'queri':19,49 'releas':86 'save/update/delete':77 'sec':47 'ship':85 'sporad':87 'suitabl':78 'transpar':52 'ttls':39 'type':84 'typescript':83 'updat':89 'version':20 'wrap':54","created_at":"2026-06-07T12:55:53.277465+00:00","updated_at":"2026-06-07T12:55:53.277465+00:00","problems":[{"fix":"const db = DatastoreAdapter(datastore);","cause":"Using new DatastoreAdapter() but version >=1.0.0 exports a factory function.","error":"TypeError: DatastoreAdapter is not a constructor"},{"fix":"npm install nsql-cache","cause":"nsql-cache is a peer dependency and must be installed separately.","error":"Cannot find module 'nsql-cache'"},{"fix":"Set GOOGLE_APPLICATION_CREDENTIALS environment variable or provide projectId in Datastore constructor.","cause":"Missing Google Cloud credentials or project ID.","error":"Error: Datastore: 3 NOT_FOUND: No project ID could be determined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/sebelga/nsql-cache-datastore#readme","github":"https://github.com/sebelga/nsql-cache-datastore","docs":null,"changelog":null,"pypi":null,"npm":"nsql-cache-datastore","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}