Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
61c7edfd
Commit
61c7edfd
authored
9 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Add cache to _get_state_groups_from_groups
parent
6ac40f7b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/state.py
+16
-3
16 additions, 3 deletions
synapse/storage/state.py
with
16 additions
and
3 deletions
synapse/storage/state.py
+
16
−
3
View file @
61c7edfd
...
...
@@ -174,6 +174,12 @@ class StateStore(SQLBaseStore):
return
[
r
[
0
]
for
r
in
results
]
return
self
.
runInteraction
(
"
get_current_state_for_key
"
,
f
)
@cached
(
num_args
=
2
,
lru
=
True
,
max_entries
=
1000
)
def
_get_state_group_from_group
(
self
,
group
,
types
):
raise
NotImplementedError
()
@cachedList
(
cached_method_name
=
"
_get_state_group_from_group
"
,
list_name
=
"
groups
"
,
num_args
=
2
,
inlineCallbacks
=
True
)
def
_get_state_groups_from_groups
(
self
,
groups
,
types
):
"""
Returns dictionary state_group -> (dict of (type, state_key) -> event id)
"""
...
...
@@ -201,18 +207,23 @@ class StateStore(SQLBaseStore):
txn
.
execute
(
sql
,
args
)
rows
=
self
.
cursor_to_dict
(
txn
)
results
=
{}
results
=
{
group
:
{}
for
group
in
groups
}
for
row
in
rows
:
key
=
(
row
[
"
type
"
],
row
[
"
state_key
"
])
results
.
setdefault
(
row
[
"
state_group
"
]
,
{})
[
key
]
=
row
[
"
event_id
"
]
results
[
row
[
"
state_group
"
]
]
[
key
]
=
row
[
"
event_id
"
]
return
results
results
=
{}
chunks
=
[
groups
[
i
:
i
+
100
]
for
i
in
xrange
(
0
,
len
(
groups
),
100
)]
for
chunk
in
chunks
:
re
turn
self
.
runInteraction
(
re
s
=
yield
self
.
runInteraction
(
"
_get_state_groups_from_groups
"
,
f
,
chunk
)
results
.
update
(
res
)
defer
.
returnValue
(
results
)
@defer.inlineCallbacks
def
get_state_for_events
(
self
,
event_ids
,
types
):
...
...
@@ -359,6 +370,8 @@ class StateStore(SQLBaseStore):
a `state_key` of None matches all state_keys. If `types` is None then
all events are returned.
"""
if
types
:
types
=
frozenset
(
types
)
results
=
{}
missing_groups
=
[]
if
types
is
not
None
:
...
...
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