google app engine - GAE Python NDB Datastore - No need for memcache.set? -
the documentation (https://cloud.google.com/appengine/docs/python/ndb/) states
ndb uses memcache cache service "hot spots" in data
i using memcache
follows: memcache.set(key=(id), value=params, time=0)
that expires (auto flushes) pretty , use ndb datastore. thought have put key-value in both ndb , memcache, check both. being done automatically ndb?
ie. ancestor_key = ndb.key("book", guestbook_name or "*notitle*")
greetings = greeting.query_book(ancestor_key).fetch(20)
would implicitly set memcache
?
and when read ndb, implicitly try memcache.get(key)
first?
thanks patience.
edit - tried:
as test tried this:
class book(ndb.model): content = ndb.stringproperty() class update(webapp2.requesthandler): def post(self): p1='1' p2='2' p3='3' p4='4' p5='5' id='test' paramarray = (p1,p2,p3,p4,p5) book = book(name=id,value=paramarray) # or likes - book = book(ndb.key(id),value=paramarray) book.put()
both versions error out. trying key of var id
values of paramarray
edit 2 daniel, thank everything.
have follow formatting questions, ask new question.
yes; see full documentation on ndb caching. basically, every write cached both in request-local in-context cache, , in main memcached store; key in both caches first before falling real datastore.
edit can't understand why think example work. defined model content
property, try set name
, value
properties on it; naturally fail.
you should go through ndb documentation, gives introduction using model class.
Comments
Post a Comment