diff options
author | Erik Johnston <erik@matrix.org> | 2015-03-02 13:53:30 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-03-02 13:53:30 +0000 |
commit | 0a036944bd2f0b42195b1984ff0ad2b6ff3d50f3 (patch) | |
tree | 25ca81b14a72192a89c9399b3d80180ac124ca14 /synapse/storage/transactions.py | |
parent | Must update pending_transactions map before yield'ing (diff) | |
parent | Merge pull request #83 from matrix-org/nofile_limit_config (diff) | |
download | synapse-0a036944bd2f0b42195b1984ff0ad2b6ff3d50f3.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into batched_get_pdu
Diffstat (limited to 'synapse/storage/transactions.py')
-rw-r--r-- | synapse/storage/transactions.py | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/synapse/storage/transactions.py b/synapse/storage/transactions.py index e06ef35690..0b8a3b7a07 100644 --- a/synapse/storage/transactions.py +++ b/synapse/storage/transactions.py @@ -13,12 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ._base import SQLBaseStore, Table +from ._base import SQLBaseStore, Table, cached from collections import namedtuple -from twisted.internet import defer - import logging logger = logging.getLogger(__name__) @@ -28,10 +26,6 @@ class TransactionStore(SQLBaseStore): """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): """For an incoming transaction from a given origin, check if we have already responded to it. If so, return the response code and response @@ -211,6 +205,7 @@ class TransactionStore(SQLBaseStore): return ReceivedTransactionsTable.decode_results(txn.fetchall()) + @cached() def get_destination_retry_timings(self, destination): """Gets the current retry timings (if any) for a given destination. @@ -221,9 +216,6 @@ class TransactionStore(SQLBaseStore): None if not retrying 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( "get_destination_retry_timings", self._get_destination_retry_timings, destination) @@ -250,7 +242,9 @@ class TransactionStore(SQLBaseStore): 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( destination, retry_last_ts, |