Ben Bleything
2/14/2008 10:11:00 PM
On Fri, Feb 15, 2008, Tony Garcia wrote:
> I need to pass information (for example, an email address) based on user
> name from a rails application to a disconnected ruby process through the
> cache. The external process has no way to know what users are being
> passed to it. I had wanted to use the user name as the key, but it seems
> that I can't find the values of current keys in the cache - at least not
> with memcache-client.
It sounds like you're trying to use the cache as a message queue, when
you should probably be using both in tandem... that is, store user data
in the cache, but send messages along the queue with the user name, so
the disconnected process can look it up in the cache.
Caching in general (and memcache in particular) are intended to speed up
slow data access, not to act as data repositories.
> So far, about the best I've found is to set the cache as a hash:
> Cache["users"] = { "user1"=>"user1@example.com",
> "user2"=>"user2@example.com" }
If you need to iterate over the usernames and the iterator has no way of
knowing what they are, that's your best bet. Not a great idea, though.
Ben