用于多个数据存储的简单、统一的api

datastore的Python项目详细描述


#数据存储

无缝无需更改应用程序代码。因此,在应用程序的整个生命周期中,不必将应用程序提交到一个数据存储中,就可以利用具有不同强度的不同数据存储。看起来是这样的:

+——+——+
应用程序<;——没有繁琐的sql或mongo特定查询!
+——+——+
<;——简单数据存储API调用
+——+——+——+
数据存储<;——底层数据库的数据存储实现
+————+——+——
<;---数据库特定调用
+——+——+
各种数据库<;——MySQL、Redis、MongoDB、FS,…
+——+——+——

分组数据存储显著简化了有趣的数据访问
模式(如缓存和分片)。




数据存储

来自源代码:

cd datastore
sudo python setup.py install


*[数据存储.git](https://github.com/datastore/datastore-git)-git实现
*[数据存储.mongo](https://github.com/datastore/datastore.mongo)-monogdb实现
*[数据存储.memcached](https://github.com/datastore/datastore.memcached)-memcached实现
*[数据存储.pylru](https://github.com/datastore/datastore.pylru)-pylru缓存实现
*[数据存储.redis](https://github.com/datastore/datastore.redis)-redis实现



网址:
http://datastore.readthedocs.org/en/latest/


它最初是[py dronestore]的一部分(https://github.com/jbenet/py dronestore)。
2011年12月,它作为一个独立项目重新编写。

项目主页:
[https://github.com/datastore/datastore](https://github.com/datastore/datastore)

但请先在github中提交问题。干杯!

贡献

实现

请为其他数据存储编写并贡献实现。这个项目只有在很多帮助下才能完成。


指南](http://google styleguide.google code.com/svn/trunk/pyguide.html)。

\``数据存储区"使用"sphinx"作为文档。查看一下``docs/``目录。

运行:

cd docs
make html
open.build/html/index.html

ds=datastore.dictdatastore()
>;
>;>;hello=datastore.key('hello')
>;>;ds.put(hello,'world')
>;>;ds.contains(hello)
true
>;>;ds.get(hello)
"world"
>;>;删除(hello)
>>>;ds.get(hello)


>>gt gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;gt;ds。ds。ds。ds。ds。ds。get(hello)
"world"
>true
>true
>>>;gt;gt;gt;ds。ds。ds。get(hello)
>none












>
>
>>
>>>>>>gt;gt;gt;gt;gt;ds。ds。ds。ds。ds。ds。get(hello(hello)

;导入pymongo
>;>import datastore.core
>;
>;>gt;
>;>from datastore.mongo导入mongodatastore
>;>from datastore.pylru导入lrucachedatastore
>;>from datastore.filesystem导入filesystemdatastore
>;>;
>;>conn=pymongo.connection()
>;>mongo=mongodatastore(conn.test廑db)
>;
>;>cache=lrucachedatastore(1000)
>;>fs=filesystemdatastore('/tmp/.test廑db')
>;
>;>ds=datastore.tiereddatastore([cache,mongo,fs])
>;
>;>;hello=datastore.key('hello')
>;>;ds.put(hello,'world')
>;>;ds.contains(hello)
true
>;>;ds.get(hello)
"world"
>;>;ds.delete(hello)
>;>ds.get(hello)
none



ds=datastore.shardeddatastore(shards)
>;
>;>hello=datastore.key('hello')
>;>ds.put(hello,'world')
>;>ds.contains(hello)
true
>;>ds.get(hello)
'world'
>;>ds.delete(hello)
>;>>;ds.get(hello)
none



\api

datastore api强调**简单**和优雅。只有四个
核心方法必须实现(get、put、delete,查询)。值)

存储由"key"命名的对象"value"。
如何序列化和存储对象取决于基础数据存储。
建议使用简单的对象(字符串、数字、列表,dicts)。

args:
key:key naming`value`
value:要存储的对象。


"query"中表示的对象匹配条件
查询的实现将是数据存储中最大的区别因素
。所有数据存储**必须**实现查询,即使使用
查询的最坏情况,有关详细信息,请参见查询类。

args:
query:描述要返回的对象的查询对象。


returns:
iterable cursor with all objects matching criteria


功能,仅与数据存储的一个子集相关,理解这些功能应以通用性为目标,并且很可能不会在其他数据存储中实现。

多个数据存储。当大量使用
特定库的特定功能时,可能不应该使用
数据存储,而应该直接使用使用这个库。

键是分层的,
包含越来越具体的名称空间。因此,键可以被视为其他键的"子"或"祖先"。


key('/commy')
key('/commy/montypython')

此外,每个命名空间都可以参数化以嵌入相关对象信息。例如,键"name"(最特定的名称空间)可以包含对象类型:


key('/commy/montypython/actor:johncleese')
key('/commy/montypython/sketch:cheeseshop')
key('/commy/montypython/sketch:cheeseshop/character:mousebender')

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
javajsoup:select(div[class=rslt prod])在不应该返回null时返回null   java如何使用selenium下载POST响应文件   Java代码在逐步调试模式下运行良好,而不是在默认运行模式下   postgresql如何检查所选区域的lat/lon是否在使用Java的数据库中定义的范围内   java在web服务中是否有类似侦听器的功能?   java如何使用Hibernate条件实现这个多重选择和where查询?   swing使用java创建图像文件   java将一个类连接到主类   java将EditText更改为TextView   Java/Kotlin在for循环中为步骤+1和if条件之前的步骤获取值   java取消@Asynchronous EJB调用   C语言中的java代理服务器#   java我应该在哪里创建构造函数,不应该在哪里创建构造函数?   Java用户输入nextLine()不等待输入   java如何在JPA元素集合中从子元素获取父元素?   java GWT代码如何使用换行符强制工具提示?   java如何停止在控制台上打印异常堆栈跟踪?