summary refs log tree commit diff
path: root/synapse/storage
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-03-23 11:43:03 +0000
committerErik Johnston <erik@matrix.org>2016-03-23 11:43:03 +0000
commit0e7363e0b3e7bf11e63259a42a0fd5922c69260e (patch)
tree9b72e71f66c290af27375ef2571f84b1699e8474 /synapse/storage
parentMeasure StateHandler._resolve_events (diff)
parentReduce cache size (diff)
downloadsynapse-0e7363e0b3e7bf11e63259a42a0fd5922c69260e.tar.xz
Merge pull request #662 from matrix-org/erikj/state_cache
Make StateHandler._state_cache only store event_ids.
Diffstat (limited to 'synapse/storage')
-rw-r--r--synapse/storage/events.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index e444b64cee..584e659d4a 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -151,6 +151,31 @@ class EventsStore(SQLBaseStore):
 
         defer.returnValue(events[0] if events else None)
 
+    @defer.inlineCallbacks
+    def get_events(self, event_ids, check_redacted=True,
+                   get_prev_content=False, allow_rejected=False):
+        """Get events from the database
+
+        Args:
+            event_ids (list): The event_ids of the events to fetch
+            check_redacted (bool): If True, check if event has been redacted
+                and redact it.
+            get_prev_content (bool): If True and event is a state event,
+                include the previous states content in the unsigned field.
+            allow_rejected (bool): If True return rejected events.
+
+        Returns:
+            Deferred : Dict from event_id to event.
+        """
+        events = yield self._get_events(
+            event_ids,
+            check_redacted=check_redacted,
+            get_prev_content=get_prev_content,
+            allow_rejected=allow_rejected,
+        )
+
+        defer.returnValue({e.event_id: e for e in events})
+
     @log_function
     def _persist_event_txn(self, txn, event, context,
                            is_new_state=True, current_state=None):