Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined when running datastore.get for non existing datastore item #6

Open
SaschaHeyer opened this issue Oct 30, 2020 · 0 comments
Open

Comments

@SaschaHeyer
Copy link

Hi Sébastien,

when running the following

    const kind = "Paths";
    const key = datastore.key([kind, parseInt(req.params.id)]);

    const [path] = await datastore.get(key);
    console.log(path)

I get this error

Error: "undefined" is not a cacheable value
    at /Users/sascha/Documents/GitHub/obfuscated/node_modules/cache-manager-redis-store/dist/index.js:88:23
    at new Promise (<anonymous>)
    at Object.mset (/Users/sascha/Documents/GitHub/obfuscated/node_modules/cache-manager-redis-store/dist/index.js:51:14)
    at NsqlCache.primeCache (/Users/sascha/Documents/GitHub/obfuscated/node_modules/nsql-cache/lib/index.js:137:14)
    at /Users/sascha/Documents/GitHub/obfuscated/node_modules/nsql-cache/lib/keys.js:104:34
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async exports.getPath (/Users/sascha/Documents/GitHub/obfuscated/Controllers/PathsController.js:77:20)
Error: "undefined" is not a cacheable value
    at /Users/sascha/Documents/GitHub/obfuscated/node_modules/cache-manager-redis-store/dist/index.js:88:23
    at new Promise (<anonymous>)
    at Object.mset (/Users/sascha/Documents/GitHub/obfuscated/node_modules/cache-manager-redis-store/dist/index.js:51:14)
    at NsqlCache.primeCache (/Users/sascha/Documents/GitHub/obfuscated/node_modules/nsql-cache/lib/index.js:137:14)
    at /Users/sascha/Documents/GitHub/obfuscated/node_modules/nsql-cache/lib/keys.js:104:34
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async exports.getPath (/Users/sascha/Documents/GitHub/obfuscated/Controllers/PathsController.js:77:20)

I would expect an undefined just like datastore does it by default.

This is the datastore wrapper


const redisStore = require("cache-manager-redis-store");
const { Datastore } = require("@google-cloud/datastore");
const NsqlCache = require("nsql-cache");
const dsAdapter = require("nsql-cache-datastore");


const datastore = new Datastore();
const cache = new NsqlCache({
    db: dsAdapter(datastore),
    stores: [{
      store: redisStore,
      host: process.env.REDIS_HOST,
      port: process.env.REDIS_HOST
    }],
});
module.exports = { datastore, cache };

Best regards
Sascha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant