跳转到主要内容

zc.monitor插件,用于修改缓存大小

项目描述

zc.montorcache 是一个 zc.z3monitor 插件,允许修改或检查正在运行的实例的缓存大小(以对象或字节为单位)。

>>> import zc.monitorcache
>>> import zope.component
>>> import zc.ngi.testing
>>> import zc.monitor
>>> import zc.monitor.interfaces
>>> import zc.z3monitor
>>> import zc.z3monitor.interfaces
>>> connection = zc.ngi.testing.TextConnection()
>>> server = zc.monitor.Server(connection)
>>> zope.component.provideUtility(zc.monitorcache.cacheMonitor,
...     zc.z3monitor.interfaces.IZ3MonitorPlugin, 'cache_size')
>>> connection.test_input('cache_size\n')
-> CLOSE

我们目前没有数据库。让我们添加一些以便测试。

>>> import ZODB.tests.util
>>> import ZODB.interfaces
>>> main = ZODB.tests.util.DB()
>>> zope.component.provideUtility(main, ZODB.interfaces.IDatabase)
>>> test = ZODB.tests.util.DB()
>>> zope.component.provideUtility(
...     test, ZODB.interfaces.IDatabase, 'test')

现在我们应该能够获取每个数据库的缓存大小信息

>>> connection = zc.ngi.testing.TextConnection()
>>> server = zc.monitor.Server(connection)
>>> connection.test_input('cache_size\n')
DB cache sizes for main
Max objects: 400
Max object size bytes: 0MB
DB cache sizes for test
Max objects: 400
Max object size bytes: 0MB
-> CLOSE

我们也可以请求特定数据库的信息

>>> connection = zc.ngi.testing.TextConnection()
>>> server = zc.monitor.Server(connection)
>>> connection.test_input('cache_size -\n')
DB cache sizes for main
Max objects: 400
Max object size bytes: 0MB
-> CLOSE
>>> connection = zc.ngi.testing.TextConnection()
>>> server = zc.monitor.Server(connection)
>>> connection.test_input('cache_size test\n')
DB cache sizes for test
Max objects: 400
Max object size bytes: 0MB
-> CLOSE

我们还可以修改特定数据库的缓存大小

>>> connection = zc.ngi.testing.TextConnection()
>>> server = zc.monitor.Server(connection)
>>> connection.test_input('cache_size test 300\n')
Set max objects to 300
-> CLOSE
>>> connection = zc.ngi.testing.TextConnection()
>>> server = zc.monitor.Server(connection)
>>> connection.test_input('cache_size test 10MB\n')
Set max object size bytes to 10MB
-> CLOSE
>>> connection = zc.ngi.testing.TextConnection()
>>> server = zc.monitor.Server(connection)
>>> connection.test_input('cache_size test\n')
DB cache sizes for test
Max objects: 300
Max object size bytes: 10MB
-> CLOSE

项目详情


下载文件

下载适用于您平台的应用程序。如果您不确定选择哪个,请了解有关 安装包 的更多信息。

源分布

zc.monitorcache-0.1.0.tar.gz (3.0 kB 查看哈希值)

上传时间:

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面