def cssdbpy_test(): conn = Connection(HOST, PORT) start_time = time() map(lambda x: conn.execute('hset','cssdbpy',str(i), 1), [i for i in xrange(10000,90000)]) print 'hset', FIELDS/(time()-start_time) start_time = time() conn.execute('hscan','cssdbpy','','', -1) print FIELDS, (time()-start_time) print 'hscan', FIELDS/(time()-start_time) for action in ['hget', 'hdel']: start_time = time() map(lambda x: conn.execute(action,'cssdbpy',str(i)), [i for i in xrange(10000,90000)]) print action, FIELDS/(time()-start_time)
def cssdbpy_test(): conn = Connection('127.0.0.1', 8888) start_time = time() map(lambda x: conn.execute('hset', 'cssdbpy', str(i), 1), [i for i in xrange(10000, 90000)]) print 'hset', time() - start_time start_time = time() conn.execute('hscan', 'cssdbpy', '', '', -1) print 'hscan', time() - start_time for action in ['hget', 'hdel']: start_time = time() map(lambda x: conn.execute(action, 'cssdbpy', str(i)), [i for i in xrange(10000, 90000)]) print action, time() - start_time
class Hashes(unittest.TestCase): def setUp(self): self.conn = Connection('127.0.0.1', 8888) def test_1hset(self): for i in xrange(0, 10): self.assertEqual(self.conn.execute('hset','test', 'test{}'.format(i), 1000), 1) def test_2hget(self): self.assertEqual(self.conn.execute('hget','test', 'test20'), 0) self.assertEqual(self.conn.execute('hget','test', 'test3'), 1000) def test_3hexists(self): self.assertEqual(self.conn.execute('hexists','test', 'test20'), 0) self.assertEqual(self.conn.execute('hexists','test', 'test3'), 1) def test_4hincr(self): self.assertEqual(self.conn.execute('hincr','test', 'test3', 1), 1001) self.assertEqual(self.conn.execute('hincr','test', 'test3', 100), 1101) def test_5hkeys(self): self.assertEqual(self.conn.execute('hkeys','test','','', -1), ['test{}'.format(i) for i in xrange(0, 10)]) def test_5hsize(self): self.assertEqual(self.conn.execute('hsize','test'), 10) def test_5hgetall(self): self.assertEqual(self.conn.execute('hgetall','test'), ['test0', '1000', 'test1', '1000', 'test2', '1000', 'test3', '1101', 'test4', '1000', 'test5', '1000', 'test6', '1000', 'test7', '1000', 'test8', '1000', 'test9', '1000']) def test_7hscan(self): self.assertEqual(self.conn.execute('hscan','test','','',-1), ['test0', '1000', 'test1', '1000', 'test2', '1000', 'test3', '1101', 'test4', '1000', 'test5', '1000', 'test6', '1000', 'test7', '1000', 'test8', '1000', 'test9', '1000']) def test_8hdel(self): self.assertEqual(self.conn.execute('hdel','test', 'empty_test'), 0) self.assertEqual(self.conn.execute('hdel','test', 'test3'), 1) def test_9hclear(self): self.assertEqual(self.conn.execute('hclear','test'), 9)
from cssdbpy import Connection from time import time import md5 if __name__ == '__main__': conn = Connection('127.0.0.1', 8888) for i in xrange(0, 10000): md5word = md5.new('word{}'.format(i)).hexdigest() create = conn.execute('hset', 'words', md5word, int(time())) value = conn.execute('hget', 'words', md5word) exists = conn.execute('hexists', 'words', md5word) delete = conn.execute('hdel', 'words', md5word) print md5word, value, create, exists, delete print conn.execute('hscan', 'words', '', '', 100) conn.execute('hclear', 'words')
from cssdbpy import Connection import md5 if __name__ == '__main__': conn = Connection('127.0.0.1', 8888) for i in xrange(0, 10000): md5word = md5.new('word{}'.format(i)).hexdigest() create = conn.execute('zset','ztest', md5word, i) value = conn.execute('zget','ztest', md5word) conn.execute('zincr','ztest', md5word) conn.execute('zincr','ztest', md5word, 10) exists = conn.execute('zexists','ztest', md5word) delete = conn.execute('zdel','ztest', md5word) print md5word, value, create, exists, delete print conn.execute('zscan', 'ztest', '', 0, 1000, 10) print conn.execute('zrscan', 'ztest', 1000, 0, 10) conn.execute('zclean','words')
class Hashes(unittest.TestCase): def setUp(self): self.conn = Connection('127.0.0.1', 8888) def test_1hset(self): for i in xrange(0, 10): self.assertEqual( self.conn.execute('hset', 'test', 'test{}'.format(i), 1000), 1) def test_2hget(self): self.assertEqual(self.conn.execute('hget', 'test', 'test20'), 0) self.assertEqual(self.conn.execute('hget', 'test', 'test3'), 1000) def test_3hexists(self): self.assertEqual(self.conn.execute('hexists', 'test', 'test20'), 0) self.assertEqual(self.conn.execute('hexists', 'test', 'test3'), 1) def test_4hincr(self): self.assertEqual(self.conn.execute('hincr', 'test', 'test3', 1), 1001) self.assertEqual(self.conn.execute('hincr', 'test', 'test3', 100), 1101) def test_5hkeys(self): self.assertEqual(self.conn.execute('hkeys', 'test', '', '', -1), ['test{}'.format(i) for i in xrange(0, 10)]) def test_5hsize(self): self.assertEqual(self.conn.execute('hsize', 'test'), 10) def test_5hgetall(self): self.assertEqual(self.conn.execute('hgetall', 'test'), [ 'test0', '1000', 'test1', '1000', 'test2', '1000', 'test3', '1101', 'test4', '1000', 'test5', '1000', 'test6', '1000', 'test7', '1000', 'test8', '1000', 'test9', '1000' ]) def test_7hscan(self): self.assertEqual(self.conn.execute('hscan', 'test', '', '', -1), [ 'test0', '1000', 'test1', '1000', 'test2', '1000', 'test3', '1101', 'test4', '1000', 'test5', '1000', 'test6', '1000', 'test7', '1000', 'test8', '1000', 'test9', '1000' ]) def test_8hdel(self): self.assertEqual(self.conn.execute('hdel', 'test', 'empty_test'), 0) self.assertEqual(self.conn.execute('hdel', 'test', 'test3'), 1) def test_9hclear(self): self.assertEqual(self.conn.execute('hclear', 'test'), 9)
from cssdbpy import Connection from time import time import md5 if __name__ == '__main__': conn = Connection('127.0.0.1', 8888) for i in xrange(0, 10000): md5word = md5.new('word{}'.format(i)).hexdigest() create = conn.execute('hset','words', md5word, int(time())) value = conn.execute('hget','words', md5word) exists = conn.execute('hexists','words', md5word) delete = conn.execute('hdel','words', md5word) print md5word, value, create, exists, delete print conn.execute('hscan', 'words', '', '', 100) conn.execute('hclear','words')
from cssdbpy import Connection import md5 if __name__ == '__main__': conn = Connection('127.0.0.1', 8888) for i in xrange(0, 10000): md5word = md5.new('word{}'.format(i)).hexdigest() create = conn.execute('zset', 'ztest', md5word, i) value = conn.execute('zget', 'ztest', md5word) conn.execute('zincr', 'ztest', md5word) conn.execute('zincr', 'ztest', md5word, 10) exists = conn.execute('zexists', 'ztest', md5word) delete = conn.execute('zdel', 'ztest', md5word) print md5word, value, create, exists, delete print conn.execute('zscan', 'ztest', '', 0, 1000, 10) print conn.execute('zrscan', 'ztest', 1000, 0, 10) conn.execute('zclean', 'words')