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
044d813e
Commit
044d813e
authored
10 years ago
by
Paul "LeoNerd" Evans
Browse files
Options
Downloads
Patches
Plain Diff
Use the @cached decorator to implement the destination_retry_timings cache
parent
357fba2c
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/storage/transactions.py
+5
-9
5 additions, 9 deletions
synapse/storage/transactions.py
with
5 additions
and
9 deletions
synapse/storage/transactions.py
+
5
−
9
View file @
044d813e
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
from
._base
import
SQLBaseStore
,
Table
from
._base
import
SQLBaseStore
,
Table
,
cached
from
collections
import
namedtuple
from
collections
import
namedtuple
...
@@ -28,10 +28,6 @@ class TransactionStore(SQLBaseStore):
...
@@ -28,10 +28,6 @@ class TransactionStore(SQLBaseStore):
"""
A collection of queries for handling PDUs.
"""
A collection of queries for handling PDUs.
"""
"""
# a write-through cache of DestinationsTable.EntryType indexed by
# destination string
destination_retry_cache
=
{}
def
get_received_txn_response
(
self
,
transaction_id
,
origin
):
def
get_received_txn_response
(
self
,
transaction_id
,
origin
):
"""
For an incoming transaction from a given origin, check if we have
"""
For an incoming transaction from a given origin, check if we have
already responded to it. If so, return the response code and response
already responded to it. If so, return the response code and response
...
@@ -211,6 +207,7 @@ class TransactionStore(SQLBaseStore):
...
@@ -211,6 +207,7 @@ class TransactionStore(SQLBaseStore):
return
ReceivedTransactionsTable
.
decode_results
(
txn
.
fetchall
())
return
ReceivedTransactionsTable
.
decode_results
(
txn
.
fetchall
())
@cached
()
def
get_destination_retry_timings
(
self
,
destination
):
def
get_destination_retry_timings
(
self
,
destination
):
"""
Gets the current retry timings (if any) for a given destination.
"""
Gets the current retry timings (if any) for a given destination.
...
@@ -221,9 +218,6 @@ class TransactionStore(SQLBaseStore):
...
@@ -221,9 +218,6 @@ class TransactionStore(SQLBaseStore):
None if not retrying
None if not retrying
Otherwise a DestinationsTable.EntryType for the retry scheme
Otherwise a DestinationsTable.EntryType for the retry scheme
"""
"""
if
destination
in
self
.
destination_retry_cache
:
return
defer
.
succeed
(
self
.
destination_retry_cache
[
destination
])
return
self
.
runInteraction
(
return
self
.
runInteraction
(
"
get_destination_retry_timings
"
,
"
get_destination_retry_timings
"
,
self
.
_get_destination_retry_timings
,
destination
)
self
.
_get_destination_retry_timings
,
destination
)
...
@@ -250,7 +244,9 @@ class TransactionStore(SQLBaseStore):
...
@@ -250,7 +244,9 @@ class TransactionStore(SQLBaseStore):
retry_interval (int) - how long until next retry in ms
retry_interval (int) - how long until next retry in ms
"""
"""
self
.
destination_retry_cache
[
destination
]
=
(
# As this is the new value, we might as well prefill the cache
self
.
get_destination_retry_timings
.
prefill
(
destination
,
DestinationsTable
.
EntryType
(
DestinationsTable
.
EntryType
(
destination
,
destination
,
retry_last_ts
,
retry_last_ts
,
...
...
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