File: pipeline-incrby.py

package info (click to toggle)
redis-py-cluster 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 748 kB
  • sloc: python: 5,888; ruby: 1,045; makefile: 542
file content (21 lines) | stat: -rw-r--r-- 652 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from redis._compat import xrange
from rediscluster import RedisCluster

startup_nodes = [{"host": "127.0.0.1", "port": 7000}]
r = RedisCluster(startup_nodes=startup_nodes, max_connections=32, decode_responses=True)

for i in xrange(1000000):
    d = str(i)
    pipe = r.pipeline(transaction=False)
    pipe.set(d, d)
    pipe.incrby(d, 1)
    pipe.execute()

    pipe = r.pipeline(transaction=False)
    pipe.set("foo-{0}".format(d), d)
    pipe.incrby("foo-{0}".format(d), 1)
    pipe.set("bar-{0}".format(d), d)
    pipe.incrby("bar-{0}".format(d), 1)
    pipe.set("bazz-{0}".format(d), d)
    pipe.incrby("bazz-{0}".format(d), 1)
    pipe.execute()