我只是在 Google App Engine 上试验 Appstats 和 NDB。
我理解 put 之后的立即获取将来自本地内存缓存,但为什么会有内存缓存删除操作?
这是全部代码:
import webapp2
from google.appengine.ext import ndb
class Specs(ndb.Model):
make = ndb.StringProperty()
model = ndb.StringProperty()
doors = ndb.IntegerProperty()
wheels = ndb.IntegerProperty()
class Car(ndb.Model):
_use_memcache = True
_use_cache = True
specs = ndb.LocalStructuredProperty(Specs)
class MainHandler(webapp2.RequestHandler):
def get(self):
my_car = Car(id='some-car')
specs = Specs(
make = "Volvo",
model = "240",
doors = 5,
wheels = 4
)
my_car.specs = specs
result = my_car.put()
my_car_by_get = result.get()
self.response.write('Saved car')
app = webapp2.WSGIApplication([
('/', MainHandler),
], debug=True)
以及 Appstats 时间线:
最佳答案
memcache.Delete()
在您使用 NDB 时在每个 put()
上被调用,因为自动缓存,这是设计使然。您可以阅读有关 NDB caching 的更多信息如果您想在缓存方面有更好的控制或不同的行为。
关于python - 为什么在这个 NDB put 操作的末尾有一个 memcache delete?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22440042/