'users' are array, which is a result of DataStore fetch as I describe
above. Not a dict. The code converts users array into memcacheable
dict. Note that same code works fine on my test GAE instance.

On Dec 3, 12:15 pm, "Ikai L (Google)" <[email protected]> wrote:
> This is a typo:
>
>     for key in cached_mapping:
>       println(self, str(obj_map[key]))
>
> Should be:
>
>     for key in cached_mapping:
>       println(self, str(cached_mapping[key]))
>
> This is tested and working for me.
>
> On Thu, Dec 3, 2009 at 12:04 PM, Ikai L (Google) <[email protected]> wrote:
>
>
>
> > What is being returned by get_multi? None or empty dictionary? Is a
> > namespace being specified?
>
> > Here's some test code that is working for me when deployed. What might you
> > be doing differently from this?
>
> > from google.appengine.ext import webapp
> > from google.appengine.ext.webapp.util import run_wsgi_app
> > from google.appengine.ext import db
>
> > from google.appengine.api import memcache
>
> > class MyThing(db.Model):
> >   name = db.StringProperty()
>
> >   def __str__(self):
> >     return "MyThing: %s" % self.name
>
> > class MemcacheTest(webapp.RequestHandler):
> >   def get(self):
> >     stats = memcache.get_stats()
>
> >     println(self, "<b>Cache Hits:%s</b><br>" % stats['hits'])
> >     println(self, "<b>Cache Misses:%s</b><br><br>" % stats['misses'])
>
> >     memcache.set("data", "My data")
> >     data = memcache.get("data")
> >     println(self, "Set 'data' -> 'My data'. Get 'data' -> " + data)
>
> >     key_range = range(1000)
> >     mapping = { }
>
> >     for i in key_range:
> >       mapping["key%d" % i] = "value %d" % i
>
> >     memcache.set_multi(mapping)
> >     println(self, "Set %d values using set_multi" % len(mapping))
>
> >     cached_mapping = memcache.get_multi(mapping.keys())
> >     println(self, "Retrieved %d values using get_multi" %
> > len(cached_mapping))
>
> >     namespace = "synccache"
> >     println(self, "Testing namespaces with namespace '%s'" % namespace)
> >     memcache.set_multi(mapping, namespace=namespace)
> >     println(self, "Set %d values using set_multi in namespace '%s'" % (
> > len(mapping), namespace ))
>
> >     cached_mapping = memcache.get_multi(mapping.keys(),
> > namespace=namespace)
> >     println(self, "Retrieved %d values using get_multi in namespace '%s'" %
> > ( len(cached_mapping), namespace ))
>
> >     println(self, "Testing objects")
> >     obj_map = {}
> >     for i in key_range:
> >       thing = MyThing(name="thing %d" % i)
> >       obj_map[thing.name] = thing
>
> >     namespace = "things"
> >     println(self, "Testing namespaces with namespace '%s'" % namespace)
> >     memcache.set_multi(obj_map, namespace=namespace)
> >     println(self, "Set %d values using set_multi in namespace '%s'" % (
> > len(mapping), namespace ))
>
> >     cached_mapping = memcache.get_multi(obj_map.keys(),
> > namespace=namespace)
> >     println(self, "Retrieved %d values using get_multi in namespace '%s'" %
> > ( len(cached_mapping), namespace ))
>
> >     for key in cached_mapping:
> >       println(self, str(obj_map[key]))
>
> > def println(handler, string):
> >   handler.response.out.write(string + "<br/>")
>
> > application = webapp.WSGIApplication([ ('/cachetest', MemcacheTest),
> >                                      ], debug=True)
>
> > def main():
> >   run_wsgi_app(application)
>
> > if __name__ == "__main__":
> >   main()
>
> > On Thu, Dec 3, 2009 at 11:09 AM, naan <[email protected]> wrote:
>
> >> I'm using memcache.set_multi() / add_multi() for caching DataStore
> >> data. Code is something like following:
>
> >>  users = User.all().query(....).fetch(...)
>
> >>  mapping = {}
> >>  for u in users:
> >>      mapping[str(u.key())] = u
>
> >>  memcache.set_multi(mapping, namespace='synccache')
>
> >> It seems that set_multi/add_multi returns correct value and there's no
> >> error logs, error messages, nor exception. However, I can't retrieve
> >> them with memcache.get_multi().
>
> >> Thanks,
> >> Kazuho
>
> >> On Dec 3, 10:46 am, "Ikai L (Google)" <[email protected]> wrote:
> >> > We've just tried this and it seems to work for us. What are you storing
> >> in
> >> > Memcache? How are you generating the keys?
>
> >> > On Thu, Dec 3, 2009 at 10:31 AM, Ikai L (Google) <[email protected]>
> >> wrote:
>
> >> > > Is there an error message when you try to store data? Do you see any
> >> > > information in the logs?
>
> >> > > On Wed, Dec 2, 2009 at 5:49 PM, naan <[email protected]> wrote:
>
> >> > >> My app id is echofonsync and the issue remains. I can get a result
> >> > >> from memcache.get_stats() now, but can not store new data. Thanks.
>
> >> > >> On Dec 2, 5:05 pm, "Ikai L (Google)" <[email protected]> wrote:
> >> > >> > Is this issue still occurring for you? If so, let me know your
> >> > >> application
> >> > >> > ID.
>
> >> > >> > Michael, let me know if this is causing you problems in production.
> >> I
> >> > >> can
> >> > >> > attempt to migrate your application to a different pool, but this
> >> is not
> >> > >> > something I'd advise if you're running in production and things are
> >> > >> working
> >> > >> > fine.
>
> >> > >> > On Wed, Dec 2, 2009 at 4:26 PM, naan <[email protected]> wrote:
> >> > >> > > Hi,
>
> >> > >> > > This happens for me too. I can't store any data into memcache.
> >> Also, I
> >> > >> > > can't get any results with memcache.get_stats(). The function
> >> returns
> >> > >> > > None.
>
> >> > >> > > On Dec 2, 1:45 pm, Michael <[email protected]> wrote:
> >> > >> > > > The problem with consistency is: the same key maps to the
> >> different
> >> > >> > > > values (when I'm hitting another memcached server), so randomly
> >> I'm
> >> > >> > > > getting old value from memcache and it produces weird effects
> >> on my
> >> > >> > > > application (like new message appearing, though they were
> >> marked as
> >> > >> > > > read).
>
> >> > >> > > > Is it going to be fixed soon?
>
> >> > >> > > > On Dec 2, 11:33 pm, Michael <[email protected]> wrote:
>
> >> > >> > > > > At the time of the first post it was going for about 10
> >> minutes.
>
> >> > >> > > > > It's still happening.
>
> >> > >> > > --
>
> >> > >> > > 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]<google-appengine%[email protected]>
> >> <google-appengine%[email protected]<google-appengine%[email protected]>
>
> >> > >> <google-appengine%[email protected]<google-appengine%[email protected]>
> >> <google-appengine%[email protected]<google-appengine%[email protected]>
>
> >> > >> > > .
> >> > >> > > For more options, visit this group at
> >> > >> > >http://groups.google.com/group/google-appengine?hl=en.
>
> >> > >> > --
> >> > >> > Ikai Lan
> >> > >> > Developer Programs Engineer, Google App Engine
>
> >> > >> --
>
> >> > >> 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]<google-appengine%[email protected]>
> >> <google-appengine%[email protected]<google-appengine%[email protected]>
>
> >> > >> .
> >> > >> For more options, visit this group at
> >> > >>http://groups.google.com/group/google-appengine?hl=en.
>
> >> > > --
> >> > > Ikai Lan
> >> > > Developer Programs Engineer, Google App Engine
>
> >> > --
> >> > Ikai Lan
> >> > Developer Programs Engineer, Google App Engine
>
> >> --
>
> >> 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]<google-appengine%[email protected]>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/google-appengine?hl=en.
>
> > --
> > Ikai Lan
> > Developer Programs Engineer, Google App Engine
>
> --
> Ikai Lan
> Developer Programs Engineer, Google App Engine

--

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.


Reply via email to