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
4b10880d
Unverified
Commit
4b10880d
authored
3 years ago
by
Richard van der Hoff
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Make sync response cache time configurable. (#10513)
parent
dc46f127
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
changelog.d/10513.feature
+1
-0
1 addition, 0 deletions
changelog.d/10513.feature
docs/sample_config.yaml
+9
-0
9 additions, 0 deletions
docs/sample_config.yaml
synapse/config/cache.py
+13
-0
13 additions, 0 deletions
synapse/config/cache.py
synapse/handlers/sync.py
+11
-3
11 additions, 3 deletions
synapse/handlers/sync.py
with
34 additions
and
3 deletions
changelog.d/10513.feature
0 → 100644
+
1
−
0
View file @
4b10880d
Add
a
configuration setting for the time a `/sync` response is cached for.
This diff is collapsed.
Click to expand it.
docs/sample_config.yaml
+
9
−
0
View file @
4b10880d
...
...
@@ -711,6 +711,15 @@ caches:
#
#expiry_time: 30m
# Controls how long the results of a /sync request are cached for after
# a successful response is returned. A higher duration can help clients with
# intermittent connections, at the cost of higher memory usage.
#
# By default, this is zero, which means that sync responses are not cached
# at all.
#
#sync_response_cache_duration: 2m
## Database ##
...
...
This diff is collapsed.
Click to expand it.
synapse/config/cache.py
+
13
−
0
View file @
4b10880d
...
...
@@ -151,6 +151,15 @@ class CacheConfig(Config):
# entries are never evicted based on time.
#
#expiry_time: 30m
# Controls how long the results of a /sync request are cached for after
# a successful response is returned. A higher duration can help clients with
# intermittent connections, at the cost of higher memory usage.
#
# By default, this is zero, which means that sync responses are not cached
# at all.
#
#sync_response_cache_duration: 2m
"""
def
read_config
(
self
,
config
,
**
kwargs
):
...
...
@@ -212,6 +221,10 @@ class CacheConfig(Config):
else
:
self
.
expiry_time_msec
=
None
self
.
sync_response_cache_duration
=
self
.
parse_duration
(
cache_config
.
get
(
"
sync_response_cache_duration
"
,
0
)
)
# Resize all caches (if necessary) with the new factors we've loaded
self
.
resize_all_caches
()
...
...
This diff is collapsed.
Click to expand it.
synapse/handlers/sync.py
+
11
−
3
View file @
4b10880d
...
...
@@ -269,14 +269,22 @@ class SyncHandler:
self
.
presence_handler
=
hs
.
get_presence_handler
()
self
.
event_sources
=
hs
.
get_event_sources
()
self
.
clock
=
hs
.
get_clock
()
self
.
response_cache
:
ResponseCache
[
SyncRequestKey
]
=
ResponseCache
(
hs
.
get_clock
(),
"
sync
"
)
self
.
state
=
hs
.
get_state_handler
()
self
.
auth
=
hs
.
get_auth
()
self
.
storage
=
hs
.
get_storage
()
self
.
state_store
=
self
.
storage
.
state
# TODO: flush cache entries on subsequent sync request.
# Once we get the next /sync request (ie, one with the same access token
# that sets 'since' to 'next_batch'), we know that device won't need a
# cached result any more, and we could flush the entry from the cache to save
# memory.
self
.
response_cache
:
ResponseCache
[
SyncRequestKey
]
=
ResponseCache
(
hs
.
get_clock
(),
"
sync
"
,
timeout_ms
=
hs
.
config
.
caches
.
sync_response_cache_duration
,
)
# ExpiringCache((User, Device)) -> LruCache(user_id => event_id)
self
.
lazy_loaded_members_cache
:
ExpiringCache
[
Tuple
[
str
,
Optional
[
str
]],
LruCache
[
str
,
str
]
...
...
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