这个API是不是太简单了? [英] Is this API too simple?

查看:21
本文介绍了这个API是不是太简单了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有许多可用的键值存储.目前你需要选择一个并坚持下去.我相信一个独立的开放 API,而不是由键值存储供应商提供的,将使存储之间的切换变得更加容易.

There are a multitude of key-value stores available. Currently you need to choose one and stick with it. I believe an independent open API, not made by a key-value store vendor would make switching between stores much easier.

因此,我正在构建一个数据存储抽象层(类似于 ODBC,但专注于更简单的键值存储),以便有人构建一次应用程序,并在必要时更改键值存储.这个API是不是太简单了?

Therefore I'm building a datastore abstraction layer (like ODBC but focused on simpler key value stores) so that someone build an app once, and change key-value stores if necessary. Is this API too simple?

get(Key)
set(Key, Value)
exists(Key)
delete(Key)

到目前为止,我看到的所有 API 似乎都添加了太多内容,我想知道还需要多少额外的方法?

As all the APIs I have seen so far seem to add so much I was wondering how many additional methods were necessary?

我收到了一些回复说 set(null) 可用于删除一个项目,如果 get 返回 null 则这意味着该项目不存在.这很糟糕,原因有二.首先,返回类型和状态混合使用不是很好,其次,并非所有语言都有空的概念.见:

I have received some replies saying that set(null) could be used to delete an item and if get returns null then this means that an item doesn't exist. This is bad for two reasons. Firstly, is it not good to mix return types and statuses, and secondly, not all languages have the concept of null. See:

进行所有编程语言对 NIL、null 或 undefined 有明确的概念吗?

我确实希望能够对数据执行多种类型的操作,但据我所知,一切都可以建立在键值存储之上.这样对吗?我也应该提供这些增值功能吗?例如:像 mapreduce 或索引

I do want to be able to perform many types of operation on the data, but as I understand it everything can be built up on top of a key value store. Is this correct? And should I provide these value added functions too? e.g: like mapreduce, or indexes

在内部,我们已经在 Erlang 和 Ruby 中提供了一个基本版本,它为我们节省了大量时间,还使我们能够针对不同键值存储的特定用例测试性能

Internally we already have a basic version of this in Erlang and Ruby and it has saved us alot of time, and also enabled us to test performance for specific use cases of different key value stores

推荐答案

您的 API 缺少一些有用的功能,例如hasKey"和clear".例如,您可能想查看 Python 的 hack,http://docs.python.org/tutorial/datastructures.html#dictionaries,然后选择附加功能.

Your API lacks some useful functions like "hasKey" and "clear". You might want to look at, say, Python's hack at it, http://docs.python.org/tutorial/datastructures.html#dictionaries, and pick and choose additional functions.

每个人都在说简单就是好的",直到简单太简单"为止都是如此.

Everyone is saying, "simple is good" and that's true until "simple is too simple."

这篇关于这个API是不是太简单了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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