Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
d6c75cb7
Commit
d6c75cb7
authored
8 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Rename and comment tree_to_leaves_iterator
parent
1ccd5676
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/util/caches/descriptors.py
+2
-2
2 additions, 2 deletions
synapse/util/caches/descriptors.py
synapse/util/caches/treecache.py
+6
-3
6 additions, 3 deletions
synapse/util/caches/treecache.py
with
8 additions
and
5 deletions
synapse/util/caches/descriptors.py
+
2
−
2
View file @
d6c75cb7
...
...
@@ -17,7 +17,7 @@ import logging
from
synapse.util.async
import
ObservableDeferred
from
synapse.util
import
unwrapFirstError
from
synapse.util.caches.lrucache
import
LruCache
from
synapse.util.caches.treecache
import
TreeCache
,
popped_to_iterator
from
synapse.util.caches.treecache
import
TreeCache
,
iterate_tree_cache_entry
from
synapse.util.logcontext
import
(
PreserveLoggingContext
,
preserve_context_over_deferred
,
preserve_context_over_fn
)
...
...
@@ -181,7 +181,7 @@ class Cache(object):
val
=
self
.
_pending_deferred_cache
.
pop
(
key
,
None
)
if
val
is
not
None
:
entry_dict
,
_
=
val
for
entry
in
popped_to_iterator
(
entry_dict
):
for
entry
in
iterate_tree_cache_entry
(
entry_dict
):
entry
.
invalidate
()
def
invalidate_all
(
self
):
...
...
This diff is collapsed.
Click to expand it.
synapse/util/caches/treecache.py
+
6
−
3
View file @
d6c75cb7
...
...
@@ -65,16 +65,19 @@ class TreeCache(object):
return
popped
def
values
(
self
):
return
list
(
popped_to_iterator
(
self
.
root
))
return
list
(
iterate_tree_cache_entry
(
self
.
root
))
def
__len__
(
self
):
return
self
.
size
def
popped_to_iterator
(
d
):
def
iterate_tree_cache_entry
(
d
):
"""
Helper function to iterate over the leaves of a tree, i.e. a dict of that
can contain dicts.
"""
if
isinstance
(
d
,
dict
):
for
value_d
in
d
.
itervalues
():
for
value
in
popped_to_iterator
(
value_d
):
for
value
in
iterate_tree_cache_entry
(
value_d
):
yield
value
else
:
if
isinstance
(
d
,
_Entry
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment