将会话存储在Memcached中时,我遇到了一个非常奇怪的问题.某些用户有时会参加其他会话.例如.约翰(John)以玛丽亚(Maria)身份登录,玛丽亚(Maria)以克里斯(Chris)等身份登录.
I have a very weird problem, when storing my session in Memcached. From time to time some users takes the session of others. E.g. John, becomes logged in as Maria, Maria as Chris and so on.
我使用Rails 2.3.4,但是早期版本的Rails也发生了相同的问题.我仅使用一台Memcache服务器,并且该服务器在同一台计算机上运行.调试的问题是我无法复制它.
I use Rails 2.3.4, but the same problem has been happening with earlier versions of Rails. I use only one Memcache server and it's running on the same machine. The problem with debugging this is that I can not reproduce it.
如果有人可以指导我如何解决此问题或对其进行调试,我将感到非常高兴.如果您正在使用Memcached进行会话并共享示例配置,我也会很高兴.
I'll be very glad if anybody can guide me how to solve this problem or debug it. I'll be also happy if you are using Memcached for sessions and you share your example confgs.
这些是我的配置:
# memcache options memcache_options = { :c_threshold => 10_000, :compression => false, :debug => false, :namespace => 'app_prod', :readonly => false, :urlencode => false, } memcache_servers = ['localhost:11211'] CACHE = MemCache.new(memcache_options) CACHE.servers = memcache_servers config.cache_store = :mem_cache_store, memcache_servers, memcache_options config.action_controller.session_store = :mem_cache_store config.action_controller.session = { :session_key => '_appname', :cache => CACHE, # :expires => 10, # :session_expires => 10, :secret => '5391aaaaaaaaaa56f8e8234beb638b97b32bbbbbbbbbbcc9dcae2beccccccccc89e8b508328def001a368da0678b061eb0e9d5a82a5ac94c8d35bd31a9a49e1' }预先感谢您, 斯坦
推荐答案我已经看到了这一点,发现调试起来非常困难.
I've seen this and found it very difficult to debug.
如果您使用的是乘客,则可能需要考虑使用保守的方法生成新服务器.
If you're using passenger, you may want to look at using the conservative method for spawning new servers.
默认方法是让服务器共享一个用于内存缓存的套接字.
The default method has servers sharing a single socket to memcache.
文档将对其进行详细讨论. www.modrails/documentation/Users%20guide%20Apache .html#_example_1_memcached_connection_sharing_harmful
The docs discuss it in more detail. www.modrails/documentation/Users%20guide%20Apache.html#_example_1_memcached_connection_sharing_harmful
更多推荐
当会话存储在memcached(Rails)中时,用户进行其他用户的会话
发布评论