Skip to content

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

@SaschaHeyer

Description

@SaschaHeyer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions