Memcached: Caching objects can be always good? (GAE Objectify)

| | August 7, 2015

Context: using Memcached. (With Google App Engine and Objectify, but this is irrelevant)

I will create a simple example, a game with two entities Player and Game. Users can often consult a single Request games that are opened or even the player profiles. There may be open 100 games or maybe 3000000 games.

(1) It is good idea to use caching for all entities? If I have unused RAM, why not use it with games or players?
Is there a bad case for this? (except take cache accessing data not at all almost no time)

(2) Another question is, when loading objects, should I partition to optimize objects stored? and cached?, for example:

player {

  punctuation          // This data will change quite frequently
  numGamesClosed       // This data will change quite frequently

Maybe better:

 @Entity     //DataStore entity
 player {

 @Cache     //The entity will be cached into Memchached
 @Entity    //DataStore entity
    @Parent Key <Player> owner;

Thanks a lot

One Response to “Memcached: Caching objects can be always good? (GAE Objectify)”

  1. Paul Collingwood on November 30, -0001 @ 12:00 AM

    The “ram” used by memcache is not from your application, it’s from a pool of memcached memory generic to GAE that is shared. All instances of your application “see” the same memcache.

    What you put into memcache does not count towards your applications ram usage.

    However the contents of memcache can be evicted at any time with no notice. So really there is no reason (apart from the upper limit on the size of the object you can put into memcache) not to cache everything, as long as you can fallback to the datastore if it’s not in cache at the time you ask for it.

Leave a Reply