im replacing "GetObjectByID" with "returnmemcache" i did a simple fuction like this
public Object returnmemcache(Class class,Key key)
{
Cache cache = null;
Object returntemp = null;
try {
CacheFactory cacheFactory =
CacheManager.getInstance().getCacheFactory();
cache = cacheFactory.createCache(Collections.emptyMap());
returntemp = cache.get(key);
if (returntemp==null)
{
PersistenceManager pm = PMF.get().getPersistenceManager();
returntemp=pm.getObjectById(class,key);
cache.put(key, returntemp);
}
} catch (CacheException e) {
PersistenceManager pm = PMF.get().getPersistenceManager();
returntemp=pm.getObjectById(class.getClass(),key);
}
return returntemp;
}
Can this be done? is there a quota to MemCache API call?
and thx again
2012/2/1 Leandro Rezende <[email protected]>
> thx for the source, now i will study a bit(googleeee) to learn how to
> "memcache" in JAVA
>
> and then i show the results, "My app without and with Memcache"
>
>
>
> 2012/2/1 Brandon Wirtz <[email protected]>
>
>>
>> http://bjk5.com/post/11766098283/app-engine-performance-hacks-youll-probably-never
>> ****
>>
>> ** **
>>
>> *Brandon Wirtz
>> *BlackWaterOps: President / Lead Mercenary ****
>>
>> [image: Description:
>> http://www.linkedin.com/img/signature/bg_slate_385x42.jpg]****
>>
>> *Work:* 510-992-6548
>> *Toll Free:* 866-400-4536 ****
>>
>> *IM:* [email protected] (Google Talk)
>> *Skype:* drakegreene
>> *YouTube:* BlackWaterOpsDotCom<http://www.youtube.com/blackwateropsdotcom>
>> **
>> ******
>>
>> BlackWater Ops <http://www.blackwaterops.com/>
>>
>> Cloud On A String Mastermind Group <http://www.cloudonastring.com/>*
>>
>> *****
>>
>> ** **
>>
>> ** **
>>
>> *From:* [email protected] [mailto:
>> [email protected]] *On Behalf Of *Leandro Rezende
>> *Sent:* Wednesday, February 01, 2012 4:38 AM
>>
>> *To:* [email protected]
>> *Subject:* Re: [google-appengine] Saving Datastore Read****
>>
>> ** **
>>
>> Thanks Brandon, ****
>>
>> So before i "GetObjectbyId()", i will search at Memcache, if the record
>> isnt there, i will "GetoBjectById()" to get data, and them store it into
>> Memcache.****
>>
>> ** **
>>
>> 2012/2/1 Brandon Wirtz <[email protected]>****
>>
>> Memcache is per App. All instances of an app will share the memcahce so
>> if instance 1 writes, instance 3 can read.****
>>
>> ****
>>
>> *Brandon Wirtz
>> *BlackWaterOps: President / Lead Mercenary ****
>>
>> [image: Description:
>> http://www.linkedin.com/img/signature/bg_slate_385x42.jpg]****
>>
>> *Work:* 510-992-6548
>> *Toll Free:* 866-400-4536 ****
>>
>> *IM:* [email protected] (Google Talk)
>> *Skype:* drakegreene
>> *YouTube:* BlackWaterOpsDotCom<http://www.youtube.com/blackwateropsdotcom>
>> ****
>>
>> BlackWater Ops <http://www.blackwaterops.com/>
>>
>> Cloud On A String Mastermind Group <http://www.cloudonastring.com/>****
>>
>> ****
>>
>> ****
>>
>> *From:* [email protected] [mailto:
>> [email protected]] *On Behalf Of *Leandro Rezende
>> *Sent:* Wednesday, February 01, 2012 3:28 AM
>> *To:* [email protected]
>> *Subject:* Re: [google-appengine] Saving Datastore Read****
>>
>> ****
>>
>> Thx for the answer Robert, i was thinking about Memcache too, but i never
>> implemented it.****
>>
>> ****
>>
>> Do u know if the data cached on memcache is public for every instance? or
>> its "private" for each browser user?****
>>
>> ****
>>
>> thank you****
>>
>> 2012/2/1 Robert Kluin <[email protected]>****
>>
>> Hi Leandro,
>> Think about the relative frequency of events. It is probably
>> massively more common to list game info than for a player to change
>> their name / image, especially once they have a lot of data. If
>> that's the case, denormalizing might be a very good choice. If
>> someone does change their name/image you can easily use the taskqueue
>> to update all their game info.
>>
>> Depending on the data, you may also be able to keep the normalized
>> model but reduce the number of reads. Just gather a list of all
>> entities you need to fetch, remove any duplicates, then get the info
>> from those entities. If there are some players who's stuff is very
>> often displayed, use memcache to store their details.
>>
>>
>> Robert****
>>
>>
>>
>>
>>
>>
>> On Tue, Jan 31, 2012 at 07:51, Leandro Rezende
>> <[email protected]> wrote:
>> > if i have 2 "Tables",
>> >
>> > "Table Player" , (Fields - PlayerKey, PlayerName, PlayerUrlPhoto)
>> > "Table PlayerGames", (Fields - PlayerGameKey, PlayerKey, GameDate)
>> >
>> > if i wanna list all games, i will create a query in "PlayerGames", and
>> to
>> > show the "Players" info, i will have to "GetObjectbyID" to read
>> PlayerName
>> > and PLayerUrlPhoto.
>> >
>> > What is the best way to do this?
>> >
>> > 1 - Using GetObjectByID is the right way (spending 1 "datastore read"
>> more
>> > for each "PlayerGame" record)
>> > 2 - Store at "PlayerGames" the fields that i know that i will need to
>> list
>> > in the future? (as playername and playerurlphoto, Saving the "DataStore
>> > read" to get Player info)
>> > 3 - Other way...
>> >
>> > * reminding that the player can change his name and his photo, so if i
>> store
>> > the name and photo at "PlayerGames" i will have to update all the
>> records
>> > too. (and will spend alot of DataStore Writes)
>> >
>> > Can someone give me a tip about this?
>> >
>> > thx
>> >****
>>
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Google App Engine" group.
>> > To post to this group, send email to [email protected].
>> > To unsubscribe from this group, send email to
>> > [email protected].
>> > For more options, visit this group at
>> > http://groups.google.com/group/google-appengine?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine?hl=en.****
>>
>> ****
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine?hl=en.****
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine?hl=en.****
>>
>> ** **
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine?hl=en.****
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine?hl=en.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.
<<image003.jpg>>
<<image002.jpg>>
