Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zodb
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Joshua
zodb
Commits
29cb71f0
Commit
29cb71f0
authored
May 03, 2008
by
Christian Theune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix for #184057: make zeo filecache not fail for small sizes
parent
3bfaa547
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
2 deletions
+106
-2
src/CHANGES.txt
src/CHANGES.txt
+3
-0
src/ZEO/cache.py
src/ZEO/cache.py
+2
-2
src/ZEO/tests/filecache.txt
src/ZEO/tests/filecache.txt
+101
-0
No files found.
src/CHANGES.txt
View file @
29cb71f0
...
...
@@ -37,6 +37,9 @@ New Features
Bugs Fixed
----------
- Fix for bug #184057: Make initialisation of small ZEO client file cache
sizes not fail.
- Fix for bug #184054: MappingStorage used to raise a KeyError during `load`
instead of a POSKeyError.
...
...
src/ZEO/cache.py
View file @
29cb71f0
...
...
@@ -684,11 +684,11 @@ class FileCache(object):
# (and it sets self.f).
self
.
fpath
=
fpath
self
.
f
=
None
if
fpath
and
os
.
path
.
exists
(
fpath
):
# Reuse an existing file. scan() will open & read it.
self
.
f
=
None
logger
.
info
(
"reusing persistent cache file %r"
,
fpath
)
el
se
:
el
if
self
.
maxsize
>=
12
:
if
fpath
:
self
.
f
=
open
(
fpath
,
'wb+'
)
logger
.
info
(
"created persistent cache file %r"
,
fpath
)
...
...
src/ZEO/tests/filecache.txt
View file @
29cb71f0
...
...
@@ -326,6 +326,107 @@ We can reset the stats by calling the `clearStats` method:
>>> fc.getStats()
(0, 0, 0, 0, 0)
Small file cache sizes
======================
The file cache requires a few bytes at the beginning of the file for itself.
Therefore cache sizes smaller than this threshold do not create a file and
will cause the cache to be disabled.
>>> obj_small = Object(key=(oid(1), tid(1)), data='#',
... start_tid=tid(1), end_tid=None)
>>> sizes = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 53, 54]
>>> for i in sizes: # doctest: +ELLIPSIS
... print "*" * 20
... print "Cache file size", i
... try:
... fc = FileCache(maxsize=i, fpath=None, parent=cache_dummy)
... except Exception, v:
... print i, v
... continue
... print "Added", fc.add(obj_small)
... print "Length", len(fc)
... print "Content", list(fc)
... print "Statistics", fc.getStats()
********************
Cache file size 0
Added False
Length 0
Content []
Statistics (0, 0, 0, 0, 0)
********************
Cache file size 1
Added False
Length 0
Content []
Statistics (0, 0, 0, 0, 0)
********************
Cache file size 2
Added False
Length 0
Content []
Statistics (0, 0, 0, 0, 0)
********************
Cache file size 3
Added False
Length 0
Content []
Statistics (0, 0, 0, 0, 0)
********************
Cache file size 4
Added False
Length 0
Content []
Statistics (0, 0, 0, 0, 0)
********************
Cache file size 5
Added False
Length 0
Content []
Statistics (0, 0, 0, 0, 0)
********************
Cache file size 6
Added False
Length 0
Content []
Statistics (0, 0, 0, 0, 0)
********************
Cache file size 7
Added False
Length 0
Content []
Statistics (0, 0, 0, 0, 0)
********************
Cache file size 8
Added False
Length 0
Content []
Statistics (0, 0, 0, 0, 0)
********************
Cache file size 9
Added False
Length 0
Content []
Statistics (0, 0, 0, 0, 0)
********************
Cache file size 10
Added False
Length 0
Content []
Statistics (0, 0, 0, 0, 0)
********************
Cache file size 53
Added False
Length 0
Content []
Statistics (0, 0, 0, 0, 0)
********************
Cache file size 54
Added True
Length 1
Content [<ZEO.cache.Entry object at 0x...>]
Statistics (1, 42, 0, 0, 0)
Cleanup
=======
...
...
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