Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
Levin Zimmermann
neoppod
Commits
5b61b676
Commit
5b61b676
authored
Jul 23, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: fix cache corruption when appending a noncurrent value
parent
3d0fab20
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
neo/client/cache.py
neo/client/cache.py
+11
-7
No files found.
neo/client/cache.py
View file @
5b61b676
...
...
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
math
from
bisect
import
insort
class
CacheItem
(
object
):
...
...
@@ -38,6 +39,9 @@ class CacheItem(object):
pass
return
'<%s%s>'
%
(
self
.
__class__
.
__name__
,
s
)
def
__lt__
(
self
,
other
):
return
self
.
tid
<
other
.
tid
class
ClientCache
(
object
):
"""In-memory pickle cache based on Multi-Queue cache algorithm
...
...
@@ -198,10 +202,7 @@ class ClientCache(object):
self
.
_oid_dict
[
oid
]
=
[
item
]
else
:
if
next_tid
:
for
i
,
x
in
enumerate
(
item_list
):
if
tid
<
x
.
tid
:
break
item_list
.
insert
(
i
,
item
)
insort
(
item_list
,
item
)
else
:
prev
=
item_list
[
-
1
]
item
.
counter
=
prev
.
counter
...
...
@@ -236,18 +237,21 @@ def test(self):
self
.
assertEqual
(
cache
.
load
(
1
,
10
),
None
)
self
.
assertEqual
(
cache
.
load
(
1
,
None
),
None
)
self
.
assertRaises
(
KeyError
,
cache
.
invalidate
,
1
,
10
)
data
=
'
foo
'
,
5
,
10
data
=
'
5
'
,
5
,
10
# 2 identical stores happens if 2 threads got a cache miss at the same time
# (which currently never happens in NEO, due to a lock)
cache
.
store
(
1
,
*
data
)
cache
.
store
(
1
,
*
data
)
self
.
assertEqual
(
cache
.
load
(
1
,
10
),
data
)
self
.
assertEqual
(
cache
.
load
(
1
,
None
),
None
)
data
=
'
bar'
,
10
,
None
data
=
'
15'
,
15
,
None
cache
.
store
(
1
,
*
data
)
self
.
assertEqual
(
cache
.
load
(
1
,
None
),
data
)
cache
.
invalidate
(
1
,
20
)
self
.
assertEqual
(
cache
.
load
(
1
,
20
),
(
'bar'
,
10
,
20
))
self
.
assertEqual
(
cache
.
load
(
1
,
20
),
(
'15'
,
15
,
20
))
cache
.
store
(
1
,
'10'
,
10
,
15
)
cache
.
store
(
1
,
'20'
,
20
,
21
)
self
.
assertEqual
([
5
,
10
,
15
,
20
],
[
x
.
tid
for
x
in
cache
.
_oid_dict
[
1
]])
if
__name__
==
'__main__'
:
import
unittest
...
...
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