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
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
ZEO
Commits
af1540ad
Commit
af1540ad
authored
Apr 13, 2002
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use cache.get() instead of has_key() & __getitem__() combo.
parent
046da4a8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
16 deletions
+21
-16
src/ZODB/Connection.py
src/ZODB/Connection.py
+21
-16
No files found.
src/ZODB/Connection.py
View file @
af1540ad
...
@@ -13,8 +13,8 @@
...
@@ -13,8 +13,8 @@
##############################################################################
##############################################################################
"""Database connection support
"""Database connection support
$Id: Connection.py,v 1.6
4 2002/03/27 10:14:03 htrd
Exp $"""
$Id: Connection.py,v 1.6
5 2002/04/13 20:17:22 jeremy
Exp $"""
__version__
=
'$Revision: 1.6
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.6
5
$'
[
11
:
-
2
]
from
cPickleCache
import
PickleCache
,
MUCH_RING_CHECKING
from
cPickleCache
import
PickleCache
,
MUCH_RING_CHECKING
from
POSException
import
ConflictError
,
ReadConflictError
from
POSException
import
ConflictError
,
ReadConflictError
...
@@ -107,10 +107,10 @@ class Connection(ExportImport.ExportImport):
...
@@ -107,10 +107,10 @@ class Connection(ExportImport.ExportImport):
try
:
del
self
.
cacheGC
try
:
del
self
.
cacheGC
except
:
pass
except
:
pass
def
__getitem__
(
self
,
oid
,
def
__getitem__
(
self
,
oid
,
tt
=
type
(())):
tt
=
type
(())):
obj
=
self
.
_cache
.
get
(
oid
,
None
)
cache
=
self
.
_cache
if
obj
is
not
None
:
if
cache
.
has_key
(
oid
):
return
cache
[
oid
]
return
obj
__traceback_info__
=
(
oid
)
__traceback_info__
=
(
oid
)
p
,
serial
=
self
.
_storage
.
load
(
oid
,
self
.
_version
)
p
,
serial
=
self
.
_storage
.
load
(
oid
,
self
.
_version
)
...
@@ -144,8 +144,9 @@ class Connection(ExportImport.ExportImport):
...
@@ -144,8 +144,9 @@ class Connection(ExportImport.ExportImport):
object
.
_p_changed
=
None
object
.
_p_changed
=
None
object
.
_p_serial
=
serial
object
.
_p_serial
=
serial
cache
[
oid
]
=
object
self
.
_cache
[
oid
]
=
object
if
oid
==
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
0
'
:
self
.
_root_
=
object
# keep a ref
if
oid
==
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
0
'
:
self
.
_root_
=
object
# keep a ref
return
object
return
object
def
_persistent_load
(
self
,
oid
,
def
_persistent_load
(
self
,
oid
,
...
@@ -153,13 +154,13 @@ class Connection(ExportImport.ExportImport):
...
@@ -153,13 +154,13 @@ class Connection(ExportImport.ExportImport):
__traceback_info__
=
oid
__traceback_info__
=
oid
cache
=
self
.
_cache
if
type
(
oid
)
is
tt
:
if
type
(
oid
)
is
tt
:
# Quick instance reference. We know all we need to know
# Quick instance reference. We know all we need to know
# to create the instance wo hitting the db, so go for it!
# to create the instance wo hitting the db, so go for it!
oid
,
klass
=
oid
oid
,
klass
=
oid
if
cache
.
has_key
(
oid
):
return
cache
[
oid
]
obj
=
self
.
_cache
.
get
(
oid
,
None
)
if
obj
is
not
None
:
return
obj
if
type
(
klass
)
is
tt
:
if
type
(
klass
)
is
tt
:
module
,
name
=
klass
module
,
name
=
klass
...
@@ -175,11 +176,13 @@ class Connection(ExportImport.ExportImport):
...
@@ -175,11 +176,13 @@ class Connection(ExportImport.ExportImport):
object
.
_p_jar
=
self
object
.
_p_jar
=
self
object
.
_p_changed
=
None
object
.
_p_changed
=
None
cache
[
oid
]
=
object
self
.
_cache
[
oid
]
=
object
return
object
return
object
if
cache
.
has_key
(
oid
):
return
cache
[
oid
]
obj
=
self
.
_cache
.
get
(
oid
,
None
)
if
obj
is
not
None
:
return
obj
return
self
[
oid
]
return
self
[
oid
]
def
_setDB
(
self
,
odb
):
def
_setDB
(
self
,
odb
):
...
@@ -219,8 +222,11 @@ class Connection(ExportImport.ExportImport):
...
@@ -219,8 +222,11 @@ class Connection(ExportImport.ExportImport):
else
:
else
:
self
.
_cache
.
invalidate
(
object
.
_p_oid
)
self
.
_cache
.
invalidate
(
object
.
_p_oid
)
def
cacheFullSweep
(
self
,
dt
=
0
):
self
.
_cache
.
full_sweep
(
dt
)
def
cacheFullSweep
(
self
,
dt
=
0
):
def
cacheMinimize
(
self
,
dt
=
0
):
self
.
_cache
.
minimize
(
dt
)
self
.
_cache
.
full_sweep
(
dt
)
def
cacheMinimize
(
self
,
dt
=
0
):
self
.
_cache
.
minimize
(
dt
)
__onCloseCallbacks
=
None
__onCloseCallbacks
=
None
...
@@ -426,7 +432,6 @@ class Connection(ExportImport.ExportImport):
...
@@ -426,7 +432,6 @@ class Connection(ExportImport.ExportImport):
self
.
_tmp
=
None
self
.
_tmp
=
None
self
.
_storage
=
tmp
self
.
_storage
=
tmp
self
.
_cache
.
invalidate
(
src
.
_index
.
keys
())
self
.
_cache
.
invalidate
(
src
.
_index
.
keys
())
self
.
_invalidate_creating
(
src
.
_creating
)
self
.
_invalidate_creating
(
src
.
_creating
)
...
...
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