Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZEO
Commits
2c7e9237
Commit
2c7e9237
authored
Mar 02, 2004
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add another test of the basic cache methods.
parent
813fb79c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
1 deletion
+73
-1
src/ZODB/tests/test_cache.py
src/ZODB/tests/test_cache.py
+73
-1
No files found.
src/ZODB/tests/test_cache.py
View file @
2c7e9237
...
...
@@ -49,10 +49,82 @@ class RecalcitrantObject(Persistent):
def
_p_deactivate
(
self
):
self
.
__class__
.
deactivations
+=
1
class
RegularObject
(
Persistent
):
deactivations
=
0
invalidations
=
0
def
_p_deactivate
(
self
):
self
.
__class__
.
deactivations
+=
1
super
(
RegularObject
,
self
).
_p_deactivate
()
def
_p_invalidate
(
self
):
self
.
__class__
.
invalidations
+=
1
super
(
RegularObject
,
self
).
_p_invalidate
()
class
CacheTests
(
unittest
.
TestCase
):
def
test_cache
(
self
):
pass
r"""Test basic cache methods.
>>> db = databaseFromString("<zodb>\n"
... "cache-size 4\n"
... "<mappingstorage/>\n"
... "</zodb>")
>>> cn = db.open()
>>> r = cn.root()
>>> L = []
>>> for i in range(5):
... o = RegularObject()
... L.append(o)
... r[i] = o
>>> get_transaction().commit()
After committing a transaction and calling cacheGC(), there
should be cache-size (4) objects in the cache. One of the
RegularObjects was deactivated.
>>> cn._cache.ringlen()
4
>>> RegularObject.deactivations
1
If we explicitly activate the objects again, the ringlen
should go back up to 5.
>>> for o in L:
... o._p_activate()
>>> cn._cache.ringlen()
5
>>> cn.cacheGC()
>>> cn._cache.ringlen()
4
>>> RegularObject.deactivations
2
>>> cn.cacheMinimize()
>>> cn._cache.ringlen()
0
>>> RegularObject.deactivations
6
If we activate all the objects again and mark one as modified,
then the one object should not be deactivated even by a
minimize.
>>> for o in L:
... o._p_activate()
>>> o.attr = 1
>>> cn._cache.ringlen()
5
>>> cn.cacheMinimize()
>>> cn._cache.ringlen()
1
>>> RegularObject.deactivations
10
"""
def
test_cache_gc_recalcitrant
(
self
):
r"""Test that a cacheGC() call will return.
...
...
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