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
Package registry
Container Registry
Model registry
Operate
Terraform modules
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
Timo Ley
synapse
Commits
d531ebcb
Commit
d531ebcb
authored
9 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Key StateHandler._state_cache off of state groups
parent
c4a8cbd1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/state.py
+21
-40
21 additions, 40 deletions
synapse/state.py
with
21 additions
and
40 deletions
synapse/state.py
+
21
−
40
View file @
d531ebcb
...
...
@@ -90,18 +90,8 @@ class StateHandler(object):
"""
event_ids
=
yield
self
.
store
.
get_latest_event_ids_in_room
(
room_id
)
cache
=
None
if
self
.
_state_cache
is
not
None
:
cache
=
self
.
_state_cache
.
get
(
frozenset
(
event_ids
),
None
)
if
cache
:
cache
.
ts
=
self
.
clock
.
time_msec
()
event_dict
=
yield
self
.
store
.
get_events
(
cache
.
state
.
values
())
state
=
{(
e
.
type
,
e
.
state_key
):
e
for
e
in
event_dict
.
values
()}
else
:
res
=
yield
self
.
resolve_state_groups
(
room_id
,
event_ids
)
state
=
res
[
1
]
res
=
yield
self
.
resolve_state_groups
(
room_id
,
event_ids
)
state
=
res
[
1
]
if
event_type
:
defer
.
returnValue
(
state
.
get
((
event_type
,
state_key
)))
...
...
@@ -193,24 +183,6 @@ class StateHandler(object):
"""
logger
.
debug
(
"
resolve_state_groups event_ids %s
"
,
event_ids
)
if
self
.
_state_cache
is
not
None
:
cache
=
self
.
_state_cache
.
get
(
frozenset
(
event_ids
),
None
)
if
cache
and
cache
.
state_group
:
cache
.
ts
=
self
.
clock
.
time_msec
()
event_dict
=
yield
self
.
store
.
get_events
(
cache
.
state
.
values
())
state
=
{(
e
.
type
,
e
.
state_key
):
e
for
e
in
event_dict
.
values
()}
prev_state
=
state
.
get
((
event_type
,
state_key
),
None
)
if
prev_state
:
prev_state
=
prev_state
.
event_id
prev_states
=
[
prev_state
]
else
:
prev_states
=
[]
defer
.
returnValue
(
(
cache
.
state_group
,
state
,
prev_states
)
)
state_groups
=
yield
self
.
store
.
get_state_groups
(
room_id
,
event_ids
)
...
...
@@ -220,7 +192,7 @@ class StateHandler(object):
state_groups
.
keys
()
)
group_names
=
set
(
state_groups
.
keys
())
group_names
=
frozen
set
(
state_groups
.
keys
())
if
len
(
group_names
)
==
1
:
name
,
state_list
=
state_groups
.
items
().
pop
()
state
=
{
...
...
@@ -234,16 +206,25 @@ class StateHandler(object):
else
:
prev_states
=
[]
if
self
.
_state_cache
is
not
None
:
cache
=
_StateCacheEntry
(
state
=
{
key
:
event
.
event_id
for
key
,
event
in
state
.
items
()},
state_
group
=
name
,
ts
=
self
.
clock
.
time_msec
()
)
defer
.
returnValue
((
name
,
state
,
prev_states
))
if
self
.
_state_cache
is
not
None
:
cache
=
self
.
_state_cache
.
get
(
group
_
name
s
,
None
)
if
cache
and
cache
.
state_group
:
cache
.
ts
=
self
.
clock
.
time_msec
(
)
self
.
_state_cache
[
frozenset
(
event_ids
)]
=
cache
event_dict
=
yield
self
.
store
.
get_events
(
cache
.
state
.
values
())
state
=
{(
e
.
type
,
e
.
state_key
):
e
for
e
in
event_dict
.
values
()}
defer
.
returnValue
((
name
,
state
,
prev_states
))
prev_state
=
state
.
get
((
event_type
,
state_key
),
None
)
if
prev_state
:
prev_state
=
prev_state
.
event_id
prev_states
=
[
prev_state
]
else
:
prev_states
=
[]
defer
.
returnValue
(
(
cache
.
state_group
,
state
,
prev_states
)
)
new_state
,
prev_states
=
self
.
_resolve_events
(
state_groups
.
values
(),
event_type
,
state_key
...
...
@@ -256,7 +237,7 @@ class StateHandler(object):
ts
=
self
.
clock
.
time_msec
()
)
self
.
_state_cache
[
f
ro
zenset
(
event_ids
)
]
=
cache
self
.
_state_cache
[
g
ro
up_names
]
=
cache
defer
.
returnValue
((
None
,
new_state
,
prev_states
))
...
...
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