3 ms·
Yea, I always use Redis for very specialized purposes. Like offloading a shared data structure between threads / processes / machines so that I don’t have to d
by brightball 2y ago
Yea, I always use Redis for very specialized purposes.
Like offloading a shared data structure between threads / processes / machines so that I don’t have to deal with thread safety issues.
- Spivak 2y agoI understand machines but threads?! Why introduce IPC overhead on the fastest/easiest way to share data? This is beyond a solved problem and your language probably has multiple ready-made battle tested solutions. In Python you don't even need a lib, dict is thread safe even in nogil.
- pdhborges 2y agoIn Python you don't even need a lib, dict is thread safe even in nogil. Is it? https://google.github.io/styleguide/pyguide.html#218-threading https://google.github.io/styleguide/pyguide.html#218-threadi...
- Spivak 2y agoYep! Not every operation you can do on a dict is thread safe but if you find a situation where it isn't it's a bug. https://github.com/python/cpython/issues/112075 https://github.com/python/cpython/issues/112075 Google is recommending people not rely on it because it does make dict subclasses not substitutable. It's easy enough to avoid the issue completely so in most cases you might as well do that.
- brightball 2y agoDepends on the use case. Often if I’m sharing data between threads there’s a good chance I’ll want to scale it to another instance at some point so just going straight to Redis is pretty common. Especially if there’s a chance I’d want that data to persist across restarts. It’s one thing if I’m using a BEAM language, but otherwise I’ll usually reach for Redis.