我正在尝试将mongodb集合保存到cacheman(npm包)中以缓存数据。
const Cacheman = require('cacheman');
const EngineMongo = require('cacheman-mongo');
// Setup cache for data from database
const engine = new EngineMongo();
const Cache = new Cacheman('users', {engine: engine});
cache.set('users', db.get('users'));
db.get('users')返回集合'users'。
设置缓存时收到以下错误:
(节点:12932)UnhandledPromiseRejectionWarning:错误:检测到循环依赖性 在serializeObject(C:\ workspace \ node_modules \ cacheman-mongo \ node_modules \ bson \ lib \ bson \ parser \ serializer.js:333:34) 在serializeInto(C:\ workspace \ node_modules \ cacheman-mongo \ node_modules \ bson \ lib \ bson \ parser \ serializer.js:937:17) 在serializeObject(C:\ workspace \ node_modules \ cacheman-mongo \ node_modules \ bson \ lib \ bson \ parser \ serializer.js:347:18) 在serializeInto(C:\ workspace \ node_modules \ cacheman-mongo \ node_modules \ bson \ lib \ bson \ parser \ serializer.js:937:17) 在serializeObject(C:\ workspace \ node_modules \ cacheman-mongo \ node_modules \ bson \ lib \ bson \ parser \ serializer.js:347:18) 在serializeInto(C:\ workspace \ node_modules \ cacheman-mongo \ node_modules \ bson \ lib \ bson \ parser \ serializer.js:937:17) 在serializeObject(C:\ workspace \ node_modules \ cacheman-mongo \ node_modules \ bson \ lib \ bson \ parser \ serializer.js:347:18) 在serializeInto(C:\ workspace \ node_modules \ cacheman-mongo \ node_modules \ bson \ lib \ bson \ parser \ serializer.js:937:17) 在serializeObject(C:\ workspace \ node_modules \ cacheman-mongo \ node_modules \ bson \ lib \ bson \ parser \ serializer.js:347:18) 在serializeInto(C:\ workspace \ node_modules \ cacheman-mongo \ node_modules \ bson \ lib \ bson \ parser \ serializer.js:937:17)
问题出在哪里?预先谢谢你。