2024-09-30 20:38:07 发布
网友
我用以下代码建立ZODB连接:
connection = ZODB.connection('zodb/connect4_reinf.fs') dbroot = connection.root()
如何设置RAM缓存大小?在
来自DB类的源代码:
def __init__(self, storage, pool_size=7, pool_timeout=1<<31, cache_size=400, cache_size_bytes=0, historical_pool_size=3, historical_cache_size=1000, historical_cache_size_bytes=0, historical_timeout=300, database_name='unnamed', databases=None, xrefs=True, large_record_size=1<<24, **storage_args):
当ZODB.connection定义如下:
ZODB.connection
我会说
connection = ZODB.connection('zodb/connect4_reinf.fs', cache_size=<your-cache-size>)
如果您希望限制为(估计的)字节,那么还有一个缓存大小字节。0表示此参数无限制。在
关于缓存大小和缓存大小字节之间的连接 (我将此贴出来作为答案,因为评论有点简短)
这次,我们可以在picklecache.py,同样在源代码中。重命名之后,可以归结为以下几行(在method\u sweep中):
for value in self.ring: if self.non_ghost_count <= target and (self.total_estimated_size <= target_size_bytes or not target_size_bytes): break (delete some objects from the cache)
这里的target是connection的cache_size,以对象数表示,target_size_bytes是传递给connection的{},以字节为单位。因此,简而言之,如果cache_size_bytes求值为False(作为默认值0,也可以是{},等等),那么只考虑对象的数量。如果cache_size_bytes存在,则cache_size和{}都要考虑在内,并且这两个条件都必须适用,即当一个对象必须被放入缓存时,如果添加将导致超过cache_size个活对象或超过cache_size_bytes字节(估计值),某些对象将从缓存中删除以释放更多可用空间。在
target
connection
cache_size
target_size_bytes
cache_size_bytes
False
0
来自DB类的源代码:
当
^{pr2}$ZODB.connection
定义如下:我会说
如果您希望限制为(估计的)字节,那么还有一个缓存大小字节。0表示此参数无限制。在
关于缓存大小和缓存大小字节之间的连接 (我将此贴出来作为答案,因为评论有点简短)
这次,我们可以在picklecache.py,同样在源代码中。重命名之后,可以归结为以下几行(在method\u sweep中):
这里的},以字节为单位。因此,简而言之,如果},等等),那么只考虑对象的数量。如果}都要考虑在内,并且这两个条件都必须适用,即当一个对象必须被放入缓存时,如果添加将导致超过
target
是connection
的cache_size
,以对象数表示,target_size_bytes
是传递给connection
的{cache_size_bytes
求值为False
(作为默认值0
,也可以是{cache_size_bytes
存在,则cache_size
和{cache_size
个活对象或超过cache_size_bytes
字节(估计值),某些对象将从缓存中删除以释放更多可用空间。在相关问题 更多 >
编程相关推荐