Here's what your code is doing in term of calls, with nbCodeTries=3

* setCodeWrongTry()
** if first call, tries = 0 
** else tries += 1 (so 1, 2, etc)
* if tries >= 2:  error

That's because in redis, INCR() returns 0 if the key does not exist yet, 
see http://redis.io/commands/INCR

This is quite redis specific, so I would suggest hiding this detail in the backend and send back 1 as first value, then simplify the test