我可以使用Cassandra存储对象吗? [英] Can I use Cassandra to store objects?

查看:345
本文介绍了我可以使用Cassandra存储对象吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序工作原理如下。

My application works like this.

有一个命令的数据库(Mysql)。该命令是一个对象(由许多字段组成的字段,如int类型的字符串)。有一个webservice与数据库交互,并从db获取命令并执行一些操作。

A database(Mysql) where there is a command. The command is an object(consists of fields many fields like ints ans strings). There is a webservice which interact with the database and get the command from the db and performs some operation.

我如何将命令存储到db中的方式是通过剥离所有并将它们插入到db中。

The way how I am storing the command into db is by stripping all the fields and inserting them in to the db.

我可以使用cassandra代替mysql并存储命令对象吗?

Can I use cassandra in place of mysql and store the command object?

推荐答案

为什么要离开目前的解决方案,包括关系数据库?我不会(相信或不)推荐更改您的数据存储库过早。

Why do you want to move away from your current solution which involes a relational database? I wouldn't (believe it or not) recommend to change your datastore premature.

如果您遇到问题并想要替换关系数据库,那么我建议您调查

If your are experience problems and want to replace your relational database, then I would recommend to investigate Apache Cassandra.

如果你发现Cassandra很有趣,我会建议一个看起来像这样的数据模型:

If you find Cassandra interesting I would suggest a data model that looks something like this:

Commands = { // this is a ColumnFamily (CF)
     commandObject1: { // this is the key to this Row inside the CF
          // now we have an infinite # of columns in this row
          field1: "value1",  
          field2: "value2",
          field3: "value3"
     }, // end row
     commandObject2: {   // this is the key to another row in the CF
          // now we have another infinite # of columns in this row
          field1: "value1",
          field2: "value2",
          field3: "value3"
          field4: "value4",
          field5: "value5"
  },
}  

(感谢Arin(和他优秀的 blog post )for the Cassandra data model notation)

(thanks Arin (and his excellent blog post) for the Cassandra data model notation)

这篇关于我可以使用Cassandra存储对象吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆