admin
admin
6214 0 0

把SQLite 当 Key-Value 数据库用

Sqlite 特性

1. ACID事务
2. 零配置 – 无需安装和管理配置
3. 储存在单一磁盘文件中的一个完整的数据库
4. 数据库文件可以在不同字节顺序的机器间自由的共享
5. 支持数据库大小至2TB
6. 足够小, 大致3万行C代码, 250K
7. 比一些流行的数据库在大部分普通数据库操作要快
8. 简单, 轻松的API
9. 包含TCL绑定, 同时通过Wrapper支持其他语言的绑定
10. 良好注释的源代码, 并且有着90%以上的测试覆盖率
11. 独立: 没有额外依赖
12. Source完全的Open, 你可以用于任何用途, 包括出售它
13. 支持多种开发语言,C, PHP, Perl, Java, ASP .NET,Python

官方给的一个key-value 用法:

Using SQLite as a Key-Value Database

The following two tables are used by these tests to store data. The intkey table uses 64-bit integer keys and arbitrary blobs for values, the blobkey table uses blobs for both key and value. So the functionality provided by the blobkey table is closest to that provided by Oracle BDB. The intkey structure is included in the tests purely because it is implemented as a special case within SQLite.

     CREATE TABLE intkey(k INTEGER PRIMARY KEY, v BLOB)
     CREATE TABLE blobkey(k BLOB PRIMARY KEY, v BLOB)
To emulate the Oracle BDB put() and get() methods on the intkey table, the following SQL statements are used with a 64-bit integer value bound to the SQL :k variable, respectively:

     INSERT INTO intkey(k, v) VALUES(:k, :v)
     SELECT v FROM intkey WHERE k = :k
The SQL queries used to provide the same functionality on the blobkey table are very similar. As one might expect, a blob value is bound to SQL variable :k for the blobkey table queries. The statements used are:

     INSERT INTO blobkey(k, v) VALUES(:k, :v)
     SELECT v FROM blobkey WHERE k = :k

参见 http://sqlite.org/cvstrac/wiki?p=KeyValueDatabase

0

See Also

Nearby


Discussion

Login Topics