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
ce2cdced
Commit
ce2cdced
authored
9 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Move cache size fiddling to descriptors only. Fix tests
parent
910fc0f2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/util/caches/descriptors.py
+2
-2
2 additions, 2 deletions
synapse/util/caches/descriptors.py
tests/storage/test_appservice.py
+7
-5
7 additions, 5 deletions
tests/storage/test_appservice.py
with
9 additions
and
7 deletions
synapse/util/caches/descriptors.py
+
2
−
2
View file @
ce2cdced
...
@@ -45,8 +45,6 @@ CACHE_SIZE_FACTOR = float(os.environ.get("SYNAPSE_CACHE_FACTOR", 0.1))
...
@@ -45,8 +45,6 @@ CACHE_SIZE_FACTOR = float(os.environ.get("SYNAPSE_CACHE_FACTOR", 0.1))
class
Cache
(
object
):
class
Cache
(
object
):
def
__init__
(
self
,
name
,
max_entries
=
1000
,
keylen
=
1
,
lru
=
True
,
tree
=
False
):
def
__init__
(
self
,
name
,
max_entries
=
1000
,
keylen
=
1
,
lru
=
True
,
tree
=
False
):
max_entries
=
int
(
max_entries
*
CACHE_SIZE_FACTOR
)
if
lru
:
if
lru
:
cache_type
=
TreeCache
if
tree
else
dict
cache_type
=
TreeCache
if
tree
else
dict
self
.
cache
=
LruCache
(
self
.
cache
=
LruCache
(
...
@@ -146,6 +144,8 @@ class CacheDescriptor(object):
...
@@ -146,6 +144,8 @@ class CacheDescriptor(object):
"""
"""
def
__init__
(
self
,
orig
,
max_entries
=
1000
,
num_args
=
1
,
lru
=
True
,
tree
=
False
,
def
__init__
(
self
,
orig
,
max_entries
=
1000
,
num_args
=
1
,
lru
=
True
,
tree
=
False
,
inlineCallbacks
=
False
):
inlineCallbacks
=
False
):
max_entries
=
int
(
max_entries
*
CACHE_SIZE_FACTOR
)
self
.
orig
=
orig
self
.
orig
=
orig
if
inlineCallbacks
:
if
inlineCallbacks
:
...
...
This diff is collapsed.
Click to expand it.
tests/storage/test_appservice.py
+
7
−
5
View file @
ce2cdced
...
@@ -35,7 +35,8 @@ class ApplicationServiceStoreTestCase(unittest.TestCase):
...
@@ -35,7 +35,8 @@ class ApplicationServiceStoreTestCase(unittest.TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
as_yaml_files
=
[]
self
.
as_yaml_files
=
[]
config
=
Mock
(
config
=
Mock
(
app_service_config_files
=
self
.
as_yaml_files
app_service_config_files
=
self
.
as_yaml_files
,
event_cache_size
=
1
,
)
)
hs
=
yield
setup_test_homeserver
(
config
=
config
)
hs
=
yield
setup_test_homeserver
(
config
=
config
)
...
@@ -109,7 +110,8 @@ class ApplicationServiceTransactionStoreTestCase(unittest.TestCase):
...
@@ -109,7 +110,8 @@ class ApplicationServiceTransactionStoreTestCase(unittest.TestCase):
self
.
as_yaml_files
=
[]
self
.
as_yaml_files
=
[]
config
=
Mock
(
config
=
Mock
(
app_service_config_files
=
self
.
as_yaml_files
app_service_config_files
=
self
.
as_yaml_files
,
event_cache_size
=
1
,
)
)
hs
=
yield
setup_test_homeserver
(
config
=
config
)
hs
=
yield
setup_test_homeserver
(
config
=
config
)
self
.
db_pool
=
hs
.
get_db_pool
()
self
.
db_pool
=
hs
.
get_db_pool
()
...
@@ -438,7 +440,7 @@ class ApplicationServiceStoreConfigTestCase(unittest.TestCase):
...
@@ -438,7 +440,7 @@ class ApplicationServiceStoreConfigTestCase(unittest.TestCase):
f1
=
self
.
_write_config
(
suffix
=
"
1
"
)
f1
=
self
.
_write_config
(
suffix
=
"
1
"
)
f2
=
self
.
_write_config
(
suffix
=
"
2
"
)
f2
=
self
.
_write_config
(
suffix
=
"
2
"
)
config
=
Mock
(
app_service_config_files
=
[
f1
,
f2
])
config
=
Mock
(
app_service_config_files
=
[
f1
,
f2
]
,
event_cache_size
=
1
)
hs
=
yield
setup_test_homeserver
(
config
=
config
,
datastore
=
Mock
())
hs
=
yield
setup_test_homeserver
(
config
=
config
,
datastore
=
Mock
())
ApplicationServiceStore
(
hs
)
ApplicationServiceStore
(
hs
)
...
@@ -448,7 +450,7 @@ class ApplicationServiceStoreConfigTestCase(unittest.TestCase):
...
@@ -448,7 +450,7 @@ class ApplicationServiceStoreConfigTestCase(unittest.TestCase):
f1
=
self
.
_write_config
(
id
=
"
id
"
,
suffix
=
"
1
"
)
f1
=
self
.
_write_config
(
id
=
"
id
"
,
suffix
=
"
1
"
)
f2
=
self
.
_write_config
(
id
=
"
id
"
,
suffix
=
"
2
"
)
f2
=
self
.
_write_config
(
id
=
"
id
"
,
suffix
=
"
2
"
)
config
=
Mock
(
app_service_config_files
=
[
f1
,
f2
])
config
=
Mock
(
app_service_config_files
=
[
f1
,
f2
]
,
event_cache_size
=
1
)
hs
=
yield
setup_test_homeserver
(
config
=
config
,
datastore
=
Mock
())
hs
=
yield
setup_test_homeserver
(
config
=
config
,
datastore
=
Mock
())
with
self
.
assertRaises
(
ConfigError
)
as
cm
:
with
self
.
assertRaises
(
ConfigError
)
as
cm
:
...
@@ -464,7 +466,7 @@ class ApplicationServiceStoreConfigTestCase(unittest.TestCase):
...
@@ -464,7 +466,7 @@ class ApplicationServiceStoreConfigTestCase(unittest.TestCase):
f1
=
self
.
_write_config
(
as_token
=
"
as_token
"
,
suffix
=
"
1
"
)
f1
=
self
.
_write_config
(
as_token
=
"
as_token
"
,
suffix
=
"
1
"
)
f2
=
self
.
_write_config
(
as_token
=
"
as_token
"
,
suffix
=
"
2
"
)
f2
=
self
.
_write_config
(
as_token
=
"
as_token
"
,
suffix
=
"
2
"
)
config
=
Mock
(
app_service_config_files
=
[
f1
,
f2
])
config
=
Mock
(
app_service_config_files
=
[
f1
,
f2
]
,
event_cache_size
=
1
)
hs
=
yield
setup_test_homeserver
(
config
=
config
,
datastore
=
Mock
())
hs
=
yield
setup_test_homeserver
(
config
=
config
,
datastore
=
Mock
())
with
self
.
assertRaises
(
ConfigError
)
as
cm
:
with
self
.
assertRaises
(
ConfigError
)
as
cm
:
...
...
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