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
7d11f825
Commit
7d11f825
authored
9 years ago
by
Mark Haines
Browse files
Options
Downloads
Plain Diff
Merge pull request #694 from matrix-org/markjh/caches
Move _get_cache_dict into the SQLBaseStore
parents
196ebaf6
a1e0d316
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/storage/__init__.py
+0
-33
0 additions, 33 deletions
synapse/storage/__init__.py
synapse/storage/_base.py
+34
-0
34 additions, 0 deletions
synapse/storage/_base.py
with
34 additions
and
33 deletions
synapse/storage/__init__.py
+
0
−
33
View file @
7d11f825
...
@@ -177,39 +177,6 @@ class DataStore(RoomMemberStore, RoomStore,
...
@@ -177,39 +177,6 @@ class DataStore(RoomMemberStore, RoomStore,
self
.
__presence_on_startup
=
None
self
.
__presence_on_startup
=
None
return
active_on_startup
return
active_on_startup
def
_get_cache_dict
(
self
,
db_conn
,
table
,
entity_column
,
stream_column
,
max_value
):
# Fetch a mapping of room_id -> max stream position for "recent" rooms.
# It doesn't really matter how many we get, the StreamChangeCache will
# do the right thing to ensure it respects the max size of cache.
sql
=
(
"
SELECT %(entity)s, MAX(%(stream)s) FROM %(table)s
"
"
WHERE %(stream)s > ? - 100000
"
"
GROUP BY %(entity)s
"
)
%
{
"
table
"
:
table
,
"
entity
"
:
entity_column
,
"
stream
"
:
stream_column
,
}
sql
=
self
.
database_engine
.
convert_param_style
(
sql
)
txn
=
db_conn
.
cursor
()
txn
.
execute
(
sql
,
(
int
(
max_value
),))
rows
=
txn
.
fetchall
()
txn
.
close
()
cache
=
{
row
[
0
]:
int
(
row
[
1
])
for
row
in
rows
}
if
cache
:
min_val
=
min
(
cache
.
values
())
else
:
min_val
=
max_value
return
cache
,
min_val
def
_get_active_presence
(
self
,
db_conn
):
def
_get_active_presence
(
self
,
db_conn
):
"""
Fetch non-offline presence from the database so that we can register
"""
Fetch non-offline presence from the database so that we can register
the appropriate time outs.
the appropriate time outs.
...
...
This diff is collapsed.
Click to expand it.
synapse/storage/_base.py
+
34
−
0
View file @
7d11f825
...
@@ -816,6 +816,40 @@ class SQLBaseStore(object):
...
@@ -816,6 +816,40 @@ class SQLBaseStore(object):
self
.
_next_stream_id
+=
1
self
.
_next_stream_id
+=
1
return
i
return
i
def
_get_cache_dict
(
self
,
db_conn
,
table
,
entity_column
,
stream_column
,
max_value
):
# Fetch a mapping of room_id -> max stream position for "recent" rooms.
# It doesn't really matter how many we get, the StreamChangeCache will
# do the right thing to ensure it respects the max size of cache.
sql
=
(
"
SELECT %(entity)s, MAX(%(stream)s) FROM %(table)s
"
"
WHERE %(stream)s > ? - 100000
"
"
GROUP BY %(entity)s
"
)
%
{
"
table
"
:
table
,
"
entity
"
:
entity_column
,
"
stream
"
:
stream_column
,
}
sql
=
self
.
database_engine
.
convert_param_style
(
sql
)
txn
=
db_conn
.
cursor
()
txn
.
execute
(
sql
,
(
int
(
max_value
),))
rows
=
txn
.
fetchall
()
txn
.
close
()
cache
=
{
row
[
0
]:
int
(
row
[
1
])
for
row
in
rows
}
if
cache
:
min_val
=
min
(
cache
.
values
())
else
:
min_val
=
max_value
return
cache
,
min_val
class
_RollbackButIsFineException
(
Exception
):
class
_RollbackButIsFineException
(
Exception
):
"""
This exception is used to rollback a transaction without implying
"""
This exception is used to rollback a transaction without implying
...
...
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