How do you generate this key-value map? All at once, or can you compute each
individual value given a key?

How do you use this map? All at once, or a few values for each web service
request?

How does the map change? All at once, or do you know which specific keys
need to be invalidated?

If you can re-compute single values easily, and if you only need a few of
them per request, and if you will invalidate single keys, then memcached is
a good fit for your project. Every time you need a value, you first check
the cache. If it's in the cache, great, you got it. If not, compute the
value, and put it in the cache. If a value changes, just remove it from
memcached, or compute it and put in the new value immediately.

How often does the map change? If it changes extremely rarely, you could
just cache the map in application memory on each individual webserver
instead, and have some mechanism for invalidating all of them at once.

Remember that memcached is a cache, it is not a permanent data store.
Putting an item into it in no way guarantees that you will get it out, it
only guarantees that if you get something out, it will be the latest version
of the item.


/Henrik

On Wed, Sep 29, 2010 at 18:18, parsa <[email protected]> wrote:

> Hey fellas,
>
> I have a large key-value map that I want to serve in a web service
> application. I want to keep a single instant of this map inside the
> memory (around 600mb footprint) and let every request that is made to
> the service use the very same object. I'm new to memcached and to be
> honest, caching in general. So is it better to keep the object in the
> memory as a whole or to add key-values to the cache separately? (btw
> I'm using Scala on Lift)
>

Reply via email to