plivo/voicechat — pull request #1 by eblume (2014-02-01 11:56:35+00:00)
Title: Pooled redis management & id creation

Hello,

In a late night bout of insomnia I saw your project on reddit, liked it, and thought I might contribute.

These changes use pooled redis connections to avoid scaling issues and potential resource leaks through unreleased connections or network threashing. Admittedly those cases would only show up under fairly heavy load, but the functionality exists, so why not?

I also replaced the tinyid function with a make_id function that stores an incremented value in redis. New ids are created by INCR'ing that value and using it as a seed for a random string in base36. I'm actually not super happy with that result, and might change it if I can think of a better scheme. Basically, what I'm trying to find is a way to go from integer -> string such that it isn't immediately obvious what the original integer was, but is still one-to-one. Anyway, using the INCR means there's no reason for a collision to EVER occur. But by using random I re-introduce that possibility. Hrm. I'll keep thinking on that one.