rya*_*yan 12 google-app-engine
有没有一种简单的方法来计算存储在App Engine中的实体的大小?我想知道一个特定实体与实体大小达到1 MB上限的接近程度.
Dav*_*ill 18
App引擎将每个实体存储为protobuf.您可以使用此处db.model_to_protobuf()描述的函数手动将实体转换为protobuf,然后使用标准方法确定其大小(以字节为单位).len()
用法示例:
from google.appengine.ext import db
sz_in_bytes = len(db.model_to_protobuf(some_entity).Encode())
Kekito在下面的评论中指出,对于ndb实体,需要采用不同的方法(谢谢Kekito!):
len(some_entity._to_pb().Encode())
| 归档时间: | 
 | 
| 查看次数: | 1810 次 | 
| 最近记录: |