【问题标题】:How to store data into cache in my case?在我的情况下如何将数据存储到缓存中?
【发布时间】:2017-05-19 01:30:00
【问题描述】:

我正在尝试使用 Nodejs 在我的应用程序中设置 AWS elasticache (memcache)。

我想将 json 对象存储到缓存中并做到了

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 在“get”之后返回 [object object] 作为字符串。

由于某种原因,如果值是字符串而不是对象,我能够设置和获取

  instance.set('profile', 'profile 1 string', false, 10000);
  instance.get('profile').then(function(cacheData){
     console.log(cacheData); // get 'profile 1 string'
  });

elasticache 可以处理 json 吗?我认为如果它不能,它会很弱。

感谢您的帮助!

【问题讨论】:

  • 我能问一下为什么要投反对票吗?

标签: javascript node.js amazon-web-services amazon-elasticache


【解决方案1】:

我们只能将 Serializable Object 存储在 Memcached 中。

【讨论】:

  • 这应该是评论,而不是答案。
猜你喜欢
  • 2021-08-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-31
  • 1970-01-01
  • 2018-09-09
相关资源
最近更新 更多