3

I'm curious about speeding up my site using memcache. Now currently I have a mysql table with columns for a key and email address, users log in using their key and I query the database to check if it's correct. The email is used incase they forget their key and want it resending.

Now, obviously each record is very small (about 19B I think). Do you think it would be a good idea to preload all (Say, 1 million records) the records into Memcached and only use Mysql for keeping a permanent record?

  • 4
    Compare the cost of a direct (indexed) retrieval from a database with the cost of a memcache retrieval... and factor in getting the data from the db to memcache in the first place.... it's a pretty trivial saving, if any. Use memcache for saving costly database queries with relatively static data, not cheap db queries. – Mark Baker Dec 24 '11 at 13:30
  • 1
    You sound like someone who would appreciate http://memcachedb.org/ – Tom van der Woerdt Dec 24 '11 at 14:03
  • Is there any performance issue that makes you want to do that? It does not seem very useful at first glance. – julien_c Dec 24 '11 at 14:34

2 Answers2

1

Memcached is intended to be a short term caching solution handle key=value pairs. While you could, in theory, use it for something like this, it isn't the intended use for it and honestly I don't think you really gain anything for it.

Generally the best thing to use Memcached for is activities like dynamically generated content that you want to keep consistent along a session and accessible from multiple servers (Like an load balanced environment.

Drahkar
  • 1,694
  • 13
  • 17
0

If you are using just 1 server, then Memcached won't prove useful. Also, when alloted memory for memcached is used completely, then memcached would overwrite the the last key. (LIFO). Storing user information in Memcache won't be ideal

Nitesh morajkar
  • 391
  • 1
  • 3
  • 11