Javascript 在我的案例中,如何将数据存储到缓存中?
我正在尝试使用Nodejs在我的应用程序中设置AWS elasticache(memcache) 我想将json对象存储到缓存中,但没有Javascript 在我的案例中,如何将数据存储到缓存中?,javascript,node.js,amazon-web-services,amazon-elasticache,Javascript,Node.js,Amazon Web Services,Amazon Elasticache,我正在尝试使用Nodejs在我的应用程序中设置AWS elasticache(memcache) 我想将json对象存储到缓存中,但没有 elastic.connect().then(function(instance){ var profile = { 'name':'Rohit kumar', 'location':'Delhi', 'emailid':'iamrohitx@gmail.com' }
elastic.connect().then(function(instance){
var profile = {
'name':'Rohit kumar',
'location':'Delhi',
'emailid':'iamrohitx@gmail.com'
}
instance.set('profile', profile, false, 10000);
instance.get('profile').then(function(cacheData){
console.log(cacheData);
});
});
cacheData
将[object object]
返回为“get
”后面的字符串
出于某种原因,我能够设置并获取值是否为string而不是object
instance.set('profile', 'profile 1 string', false, 10000);
instance.get('profile').then(function(cacheData){
console.log(cacheData); // get 'profile 1 string'
});
elasticache能处理json吗?我想如果它不能,它会很弱
谢谢你的帮助 我们只能将可序列化对象存储在Memcached中。我可以问一下为什么要进行向下投票吗?这应该是一个注释,而不是答案。