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
Ivan Tyagov
neoppod
Commits
254878a8
Commit
254878a8
authored
Mar 02, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: optimize cache by not keeping items with counter=0 in history queue
parent
763806e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
neo/client/cache.py
neo/client/cache.py
+18
-7
No files found.
neo/client/cache.py
View file @
254878a8
...
...
@@ -60,6 +60,7 @@ class ClientCache(object):
- Each access "ages" objects in cache, and an aging object is moved to
shorter-lived queue as it ages without being accessed, or in the
history queue if it's really too old.
- The history queue only contains items with counter > 0
"""
__slots__
=
(
'_life_time'
,
'_max_history_size'
,
'_max_size'
,
...
...
@@ -159,7 +160,10 @@ class ClientCache(object):
for
head
in
self
.
_queue_list
[
1
:]:
if
head
and
head
.
expire
<
time
:
self
.
_remove
(
head
)
self
.
_add
(
head
)
if
head
.
level
or
head
.
counter
:
self
.
_add
(
head
)
else
:
self
.
_oid_dict
[
head
.
oid
].
remove
(
head
)
break
def
_load
(
self
,
oid
,
before_tid
=
None
):
...
...
@@ -223,10 +227,14 @@ class ClientCache(object):
prev
=
item_list
[
-
1
]
assert
prev
.
next_tid
<=
tid
,
(
prev
,
item
)
item
.
counter
=
prev
.
counter
prev
.
counter
=
0
if
prev
.
level
>
1
:
self
.
_fetched
(
prev
)
item_list
.
append
(
item
)
if
prev
.
level
:
prev
.
counter
=
0
if
prev
.
level
>
1
:
self
.
_fetched
(
prev
)
item_list
.
append
(
item
)
else
:
self
.
_remove
(
prev
)
item_list
[
-
1
]
=
item
item
.
data
=
data
self
.
_fetched
(
item
)
self
.
_size
+=
size
...
...
@@ -234,8 +242,11 @@ class ClientCache(object):
for
head
in
self
.
_queue_list
[
1
:]:
while
head
:
next
=
self
.
_remove
(
head
)
head
.
level
=
0
self
.
_add
(
head
)
if
head
.
counter
:
head
.
level
=
0
self
.
_add
(
head
)
else
:
self
.
_oid_dict
[
head
.
oid
].
remove
(
head
)
if
self
.
_size
<=
max_size
:
return
head
=
next
...
...
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