python - appengine: cached reference property? -
I How can cache a reference property in Google App Engine
For example, suppose that I have the following model:
class number (db.Model): a = db.ReferenceProperty (a) class a few (db.Model): year = db.IntegerProperty ()
Then I have many many
that only make a point for something
:
one_few = Few.get_or_insert (year = 2009) Many.get_or_insert (a = one_few) Many.get_or_insert (a = one_few) Many.get_or_insert (a = one_few) Many.get_or_insert (a = one_few) Many.get_or_insert (a = one_few) M any.get_or_insert (a = One_few)
Now, if I all wants very frequent in
do, then your some
value By reading, I will do this:
Many for many () Fetch (1000): Print "% s" is% many.few.year
The question is:
- Is
many.few
- If so, is it possible to cache something, because every single unit should be enough for the same lookup every time?
As noted in a comment: I know about Memkac, but I'm not sure when I will call the second unit through a reference , Then I can "inject" it.
In any case memcache will not be useful, because I need caching within the execution, not between them. Using the memcache will not help optimize this call.
any reference asset variation first time you've been receiving unit - even if you already have Acquire the same unit connected to different reference properties. It includes a datastore operation, which is not as expensive as a query, but still if you can, it is worth it.
A good module is available that seamless caching of the available organizations works at a lower level of this datastore, and all the datastas are cached, just not to mention ReferenceProperties
you Once you want to solve a group of contextual properties, there will be another way out. You can get all the keys and do not bring the units in a single round trip so:
key = [in referers for myModel.ref.get_value_for_datastore (x) x] ref = db Finally, I have written a library that closes the DB module on the basis of a per-request locally cached institutions (no memacatch is included). It is available, . A warning, though: This unit is tested, but it has not been widely used, so it can be broken.
Comments
Post a Comment