Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
537cb142
Commit
537cb142
authored
Nov 03, 2003
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix collector issue #1105:
Make the cache manager report correct values for the object cache size.
parent
27067290
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
26 deletions
+98
-26
doc/CHANGES.txt
doc/CHANGES.txt
+3
-0
lib/python/App/CacheManager.py
lib/python/App/CacheManager.py
+10
-26
lib/python/App/tests/test_cachemanager.py
lib/python/App/tests/test_cachemanager.py
+85
-0
No files found.
doc/CHANGES.txt
View file @
537cb142
...
...
@@ -30,6 +30,9 @@ Zope Changes
Bugs fixed
- Made the control panel properly reflect the cache-size setting
of ZODB's object cache once again.
- ConflictError was swallowed in ObjectManager by
manage_beforeDelete and _delObject. This could break code
expecting to do cleanups before deletion.
...
...
lib/python/App/CacheManager.py
View file @
537cb142
...
...
@@ -13,8 +13,8 @@
__doc__
=
'''Cache management support
$Id: CacheManager.py,v 1.2
7 2002/10/09 15:11:25 shan
e Exp $'''
__version__
=
'$Revision: 1.2
7
$'
[
11
:
-
2
]
$Id: CacheManager.py,v 1.2
8 2003/11/03 16:40:37 fdrak
e Exp $'''
__version__
=
'$Revision: 1.2
8
$'
[
11
:
-
2
]
import
Globals
,
time
,
sys
from
DateTime
import
DateTime
...
...
@@ -23,9 +23,7 @@ class CacheManager:
"""Cache management mix-in
"""
_cache_age
=
60
_cache_size
=
400
_vcache_age
=
60
_vcache_size
=
400
_history_length
=
3600
# Seconds
manage_cacheParameters
=
Globals
.
DTMLFile
(
'dtml/cacheParameters'
,
globals
())
...
...
@@ -86,14 +84,12 @@ class CacheManager:
response
=
REQUEST
[
'RESPONSE'
]
response
.
redirect
(
REQUEST
[
'URL1'
]
+
'/manage_cacheParameters'
)
def
cache_size
(
self
):
try
:
if
self
.
_p_jar
.
getVersion
():
return
self
.
_
vcache_size
return
self
.
_
p_jar
.
db
().
getVersionCacheSize
()
except
:
pass
return
self
.
_
cache_size
return
self
.
_
p_jar
.
db
().
getCacheSize
()
def
manage_cache_size
(
self
,
value
,
REQUEST
):
"set cache size"
...
...
@@ -105,14 +101,13 @@ class CacheManager:
raise
'Version Error'
,
(
'''You may not change the database cache size
while working in a <em>version</em>'''
)
self
.
_cache_size
=
Globals
.
Bobobase
.
_jar
.
cache
.
cache_size
=
value
Globals
.
Bobobase
.
_jar
.
cache
.
cache_size
=
value
else
:
db
=
self
.
_p_jar
.
db
()
if
v
:
self
.
_vcache_size
=
value
self
.
_p_jar
.
db
().
setVersionCacheSize
(
value
)
db
.
setVersionCacheSize
(
value
)
else
:
self
.
_cache_size
=
value
self
.
_p_jar
.
db
().
setCacheSize
(
value
)
db
.
setCacheSize
(
value
)
if
REQUEST
is
not
None
:
response
=
REQUEST
[
'RESPONSE'
]
...
...
@@ -181,19 +176,8 @@ class CacheManager:
response
.
redirect
(
REQUEST
[
'URL1'
]
+
'/manage_cacheGC'
)
def
initialize_cache
(
self
):
try
:
db
=
self
.
_p_jar
.
db
()
except
:
# BoboPOS2
Globals
.
Bobobase
.
_jar
.
cache
.
cache_size
=
self
.
_cache_size
Globals
.
Bobobase
.
_jar
.
cache
.
cache_age
=
self
.
_cache_age
else
:
db
.
setCacheSize
(
self
.
_cache_size
)
db
.
setCacheDeactivateAfter
(
self
.
_cache_age
)
db
.
setVersionCacheSize
(
self
.
_vcache_size
)
db
.
setVersionCacheDeactivateAfter
(
self
.
_vcache_age
)
am
=
self
.
_getActivityMonitor
()
if
am
is
not
None
:
am
.
setHistoryLength
(
self
.
_history_length
)
# Cache is always initialized from the configuration file.
pass
def
cache_detail
(
self
,
REQUEST
=
None
):
"""
...
...
lib/python/App/tests/test_cachemanager.py
0 → 100644
View file @
537cb142
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Tests for the CacheManager.
$Id: test_cachemanager.py,v 1.1 2003/11/03 16:40:37 fdrake Exp $
"""
import
unittest
import
ZODB
from
App.CacheManager
import
CacheManager
class
TestCacheManager
(
CacheManager
):
# Derived CacheManager that fakes enough of the DatabaseManager to
# make it possible to test at least some parts of the CacheManager.
def
__init__
(
self
,
connection
):
self
.
_p_jar
=
connection
class
DummyConnection
:
def
__init__
(
self
,
db
,
version
=
None
):
self
.
__db
=
db
self
.
__version
=
version
def
db
(
self
):
return
self
.
__db
def
getVersion
(
self
):
return
self
.
__version
class
DummyDB
:
def
__init__
(
self
,
cache_size
,
vcache_size
):
self
.
_set_sizes
(
cache_size
,
vcache_size
)
def
_set_sizes
(
self
,
cache_size
,
vcache_size
):
self
.
__cache_size
=
cache_size
self
.
__vcache_size
=
vcache_size
def
getCacheSize
(
self
):
return
self
.
__cache_size
def
getVersionCacheSize
(
self
):
return
self
.
__vcache_size
class
CacheManagerTestCase
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
db
=
DummyDB
(
42
,
24
)
self
.
connection
=
DummyConnection
(
self
.
db
)
self
.
manager
=
TestCacheManager
(
self
.
connection
)
def
test_cache_size
(
self
):
self
.
assertEqual
(
self
.
manager
.
cache_size
(),
42
)
self
.
db
.
_set_sizes
(
12
,
2
)
self
.
assertEqual
(
self
.
manager
.
cache_size
(),
12
)
def
test_version_cache_size
(
self
):
self
.
connection
=
DummyConnection
(
self
.
db
,
"my version"
)
self
.
manager
=
TestCacheManager
(
self
.
connection
)
# perform test
self
.
assertEqual
(
self
.
manager
.
cache_size
(),
24
)
self
.
db
.
_set_sizes
(
12
,
2
)
self
.
assertEqual
(
self
.
manager
.
cache_size
(),
2
)
def
test_suite
():
return
unittest
.
makeSuite
(
CacheManagerTestCase
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment