0

I'm trying out Redis and i'm not sure where i'm going wrong with my setup

when r.lpush() is called I assume it would insert a value into my list and lengthen the list by one but when llen() is called the length increases by a random amount each time I run this script

import redis

class RedisConnection:
    def __init__(self):
        config = {
            'host': 'redis',
            'port': 6379,
        }
    self.client = redis.Redis(**config)

    def getClient(self):
        return self.client

r = RedisConnection().getClient()
r.rpush("lst1", 6)

print r.llen("lst1")

each time I run the script the length of the list goes up an arbitrary amount

EDIT: So after checking the before length and after length it is increasing by one but here is the output after running the script multiple times

BEFORE: 1 AFTER: 2

BEFORE: 5 AFTER: 6

BEFORE: 16 AFTER: 17

Not sure whats causing those jumps after each run though

EDIT: Output of the redis MONITOR command

This is the output after the above script is run exactly once. The rpush("lst1", 6) command keeps running over and over a bunch of times and I think it's something to do with my Docker config

My Docker config is:

app:
  restart: always
  build: ./app/
  expose:
    - "8000"
  links:
    - redis:redis
  volumes:
    - ./app:/usr/src/app
  env_file: .env
  command: /usr/local/bin/gunicorn mytestapp.wsgi:application -w 2 -b :8000

redis:
  restart: always
  build: ./redis/
  expose:
    - "6379"
  volumes:
    - redisdata:/data

Redis Dockerfile:

FROM redis:latest

I've tried redis with restart:always and without it

Redis Monitor Output:

root@e2343dec33da: redis-cli -h redis MONITOR
OK
1467344153.562365 [0 172.17.0.16:35002] "RPUSH" "lst1" "6"
1467344153.563107 [0 172.17.0.16:35002] "LLEN" "lst1"
1467344154.281957 [0 172.17.0.16:35004] "RPUSH" "lst1" "6"
1467344154.282407 [0 172.17.0.16:35004] "LLEN" "lst1"
1467344155.072393 [0 172.17.0.16:35006] "RPUSH" "lst1" "6"
1467344155.073077 [0 172.17.0.16:35006] "LLEN" "lst1"
1467344156.081633 [0 172.17.0.16:35008] "RPUSH" "lst1" "6"
1467344156.082258 [0 172.17.0.16:35008] "LLEN" "lst1"
1467344156.329652 [0 172.17.0.15:43952] "RPUSH" "lst1" "6"
1467344156.330195 [0 172.17.0.15:43952] "LLEN" "lst1"
1467344157.494998 [0 172.17.0.16:35012] "RPUSH" "lst1" "6"
1467344157.495581 [0 172.17.0.16:35012] "LLEN" "lst1"
1467344159.675782 [0 172.17.0.16:35014] "RPUSH" "lst1" "6"
1467344159.677411 [0 172.17.0.16:35014] "LLEN" "lst1"
1467344163.432896 [0 172.17.0.16:35016] "RPUSH" "lst1" "6"
1467344163.433910 [0 172.17.0.16:35016] "LLEN" "lst1"
1467344169.653969 [0 172.17.0.15:43960] "RPUSH" "lst1" "6"
1467344169.654669 [0 172.17.0.15:43960] "LLEN" "lst1"
1467344170.446384 [0 172.17.0.16:35020] "RPUSH" "lst1" "6"
1467344170.447025 [0 172.17.0.16:35020] "LLEN" "lst1"
1467344172.540838 [0 172.17.0.14:44806] "RPUSH" "lst1" "6"
1467344172.541958 [0 172.17.0.14:44806] "LLEN" "lst1"
1467344183.797716 [0 172.17.0.16:35024] "RPUSH" "lst1" "6"
1467344183.798663 [0 172.17.0.16:35024] "LLEN" "lst1"
1467344195.843937 [0 172.17.0.15:43968] "RPUSH" "lst1" "6"
1467344195.844140 [0 172.17.0.15:43968] "LLEN" "lst1"
1467344209.951857 [0 172.17.0.16:35028] "RPUSH" "lst1" "6"
1467344209.952459 [0 172.17.0.16:35028] "LLEN" "lst1"
1467344224.430525 [0 172.17.0.14:44814] "RPUSH" "lst1" "6"
1467344224.430922 [0 172.17.0.14:44814] "LLEN" "lst1"
1467344247.764961 [0 172.17.0.15:43974] "RPUSH" "lst1" "6"
1467344247.766123 [0 172.17.0.15:43974] "LLEN" "lst1"
1467344261.729253 [0 172.17.0.16:35034] "RPUSH" "lst1" "6"
1467344261.729680 [0 172.17.0.16:35034] "LLEN" "lst1"
1467344284.244204 [0 172.17.0.13:49524] "RPUSH" "lst1" "6"
1467344284.245552 [0 172.17.0.13:49524] "LLEN" "lst1"
1467344327.393265 [0 172.17.0.14:44822] "RPUSH" "lst1" "6"
1467344327.394594 [0 172.17.0.14:44822] "LLEN" "lst1"
1467344350.752738 [0 172.17.0.15:43982] "RPUSH" "lst1" "6"
1467344350.753683 [0 172.17.0.15:43982] "LLEN" "lst1"
1467344365.029118 [0 172.17.0.16:35042] "RPUSH" "lst1" "6"
1467344365.029599 [0 172.17.0.16:35042] "LLEN" "lst1"
Jay Syko
  • 71
  • 2
  • 6

0 Answers0