#设a为字符串
import time
a = "2011-09-28 10:00:00"
#中间过程,一般都需要将字符串转化为时间数组
time.strptime(a,'%Y-%m-%d %H:%M:%S')
>>time.struct_time(tm_year=2011, tm_mon=9, tm_mday=27, tm_hour=10, tm_min=50, tm_sec=0, tm_wday=1, tm_yday=270, tm_isdst=-1)
#将"[......]
#设a为字符串
import time
a = "2011-09-28 10:00:00"
#中间过程,一般都需要将字符串转化为时间数组
time.strptime(a,'%Y-%m-%d %H:%M:%S')
>>time.struct_time(tm_year=2011, tm_mon=9, tm_mday=27, tm_hour=10, tm_min=50, tm_sec=0, tm_wday=1, tm_yday=270, tm_isdst=-1)
#将"[......]
C++中Trim的方法,其实也是写的很Trick的……
参考:http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring
#include <stringstream>
void trim(::std::string & str)
{
//left
str.erase(str.begin(), std::find_if(str.begin(),[......]
理论上讲,Python是不存在线程安全问题的,由于GIT么,但是这是有前提的:sleep,I/O导致的wait都可能会引发线程安全隐患。
同理,gevent是基于事件驱动模型的,就不太可能是线程安全的。
gevent.coros.Semaphore提供了信号量的功能,可以是n个哦!
semaphore.acquire() -> 获取“锁”
semaphore.release() -> 释放“锁”
gevent的文档写的真简介啊,于是测试了个基本的同步方法:同[......]
2011.9.25更新
本文被转载到NoSQLFun进行讨论
我才发现原文的一些问题没有表述清楚:
1、本文主要是针对随机读,而非随机写,关于如何构造一个写快的NoSQL系统,见BigTable论文,或者Cassandra、HBase。
2、我实际遇到的都是随机读很慢的情况,热数据可以解决部分问题,但是当规模远大于你的机器规模的时候,还是无法逾越的问题,此时NoSQL相对于RDBMS的优势就小的可怜了。
欢迎继续进行探讨。
原文:
抱歉我用了这么一个标题[......]