简体   繁体   English

使用键值存储构建应用程序的设计策略

[英]Design strategies for building applications using Key-value store

Key-value store, a type of NoSQL, how can it be used to build common application functions?键值存储,NoSQL的一种,怎么可以用来构建常用的应用功能呢?

  • Storing user information (login information)存储用户信息(登录信息)
  • Storing documents and/or "entities" with relation to a user or other entities存储与用户或其他实体相关的文档和/或“实体”

What is the general strategy in modeling application that uses Key-Value store instead of a typical document NoSQL?使用键值存储而不是典型文档 NoSQL 的建模应用程序的一般策略是什么?

For example if you only have this API to interface to the datastore:例如,如果您只有这个 API 来连接数据存储:

put(String bucketName, String, byte[] value);
byte[] get(String bucketName, String key);
List<String> getKeys(String bucketName, String prefix, int maxKeys);
delete(String bucketName, String key); 

One answer to this question as described here .here所述,此问题的一个答案。

Is to model information like this:是这样的model信息:

[key]           [value]
artist:1:name   AC/DC
artist:1:genre  Hard Rock
artist:2:name   Slim Dusty
artist:2:genre  Country

The problem here is if the underlying datastore does not support transactions then missing data in a set might occur.这里的问题是,如果底层数据存储不支持事务,那么可能会出现一组数据丢失的情况。 However a good end-user application design that understand that each data stored for example, the artist entity are actually multiple values stored, then that would not be a problem.然而,一个好的最终用户应用程序设计理解存储的每个数据,例如,艺术家实体实际上存储了多个值,那么这将不是问题。 The key here is the application must "understand" that the database in use is a Key-Value stored, much like how DNS registrations are designed with each record is saved individually instead of batch, which will be the usual case since most KV store can't handle batch operations.这里的关键是应用程序必须“理解”正在使用的数据库是一个键值存储,就像 DNS 注册的设计方式一样,每条记录都是单独保存而不是批量保存,这将是通常的情况,因为大多数 KV 存储都可以'不处理批处理操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM