summary refs log tree commit diff
path: root/synapse/config
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2015-02-11 15:44:09 +0000
committerMark Haines <mjark@negativecurvature.net>2015-02-11 15:44:09 +0000
commit40f332e5348bd301bb623870eddb3adf1ca363f3 (patch)
tree20f3eda004e9b35217263033a525382dbaac6422 /synapse/config
parentMention new libs in CHANGES (diff)
parentInvalidate the cache for an event if it is redacted (diff)
downloadsynapse-40f332e5348bd301bb623870eddb3adf1ca363f3.tar.xz
Merge pull request #65 from matrix-org/get_event_cache
Add an in-memory cache for get_event in the storage layer
Diffstat (limited to 'synapse/config')
-rw-r--r--synapse/config/_base.py10
-rw-r--r--synapse/config/database.py5
2 files changed, 15 insertions, 0 deletions
diff --git a/synapse/config/_base.py b/synapse/config/_base.py
index 9b0f8c3c32..87cdbf1d30 100644
--- a/synapse/config/_base.py
+++ b/synapse/config/_base.py
@@ -28,6 +28,16 @@ class Config(object):
         pass
 
     @staticmethod
+    def parse_size(string):
+        sizes = {"K": 1024, "M": 1024 * 1024}
+        size = 1
+        suffix = string[-1]
+        if suffix in sizes:
+            string = string[:-1]
+            size = sizes[suffix]
+        return int(string) * size
+
+    @staticmethod
     def abspath(file_path):
         return os.path.abspath(file_path) if file_path else file_path
 
diff --git a/synapse/config/database.py b/synapse/config/database.py
index daa161c952..87efe54645 100644
--- a/synapse/config/database.py
+++ b/synapse/config/database.py
@@ -24,6 +24,7 @@ class DatabaseConfig(Config):
             self.database_path = ":memory:"
         else:
             self.database_path = self.abspath(args.database_path)
+        self.event_cache_size = self.parse_size(args.event_cache_size)
 
     @classmethod
     def add_arguments(cls, parser):
@@ -33,6 +34,10 @@ class DatabaseConfig(Config):
             "-d", "--database-path", default="homeserver.db",
             help="The database name."
         )
+        db_group.add_argument(
+            "--event-cache-size", default="100K",
+            help="Number of events to cache in memory."
+        )
 
     @classmethod
     def generate_config(cls, args, config_dir_path):