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
Package registry
Container registry
Model registry
Operate
Terraform modules
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
Timo Ley
synapse
Commits
2cd6cb9f
Commit
2cd6cb9f
authored
9 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Rename keyargs to args in Cache
parent
2352974a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/_base.py
+9
-9
9 additions, 9 deletions
synapse/storage/_base.py
with
9 additions
and
9 deletions
synapse/storage/_base.py
+
9
−
9
View file @
2cd6cb9f
...
...
@@ -86,8 +86,8 @@ class Cache(object):
"
Cache objects can only be accessed from the main thread
"
)
def
get
(
self
,
key
args
,
default
=
_CacheSentinel
):
val
=
self
.
cache
.
get
(
key
args
,
_CacheSentinel
)
def
get
(
self
,
key
,
default
=
_CacheSentinel
):
val
=
self
.
cache
.
get
(
key
,
_CacheSentinel
)
if
val
is
not
_CacheSentinel
:
cache_counter
.
inc_hits
(
self
.
name
)
return
val
...
...
@@ -99,29 +99,29 @@ class Cache(object):
else
:
return
default
def
update
(
self
,
sequence
,
key
args
,
value
):
def
update
(
self
,
sequence
,
key
,
value
):
self
.
check_thread
()
if
self
.
sequence
==
sequence
:
# Only update the cache if the caches sequence number matches the
# number that the cache had before the SELECT was started (SYN-369)
self
.
prefill
(
key
args
,
value
)
self
.
prefill
(
key
,
value
)
def
prefill
(
self
,
key
args
,
value
):
def
prefill
(
self
,
key
,
value
):
if
self
.
max_entries
is
not
None
:
while
len
(
self
.
cache
)
>=
self
.
max_entries
:
self
.
cache
.
popitem
(
last
=
False
)
self
.
cache
[
key
args
]
=
value
self
.
cache
[
key
]
=
value
def
invalidate
(
self
,
key
args
):
def
invalidate
(
self
,
key
):
self
.
check_thread
()
if
not
isinstance
(
key
args
,
tuple
):
if
not
isinstance
(
key
,
tuple
):
raise
ValueError
(
"
keyargs must be a tuple.
"
)
# Increment the sequence number so that any SELECT statements that
# raced with the INSERT don't update the cache (SYN-369)
self
.
sequence
+=
1
self
.
cache
.
pop
(
key
args
,
None
)
self
.
cache
.
pop
(
key
,
None
)
def
invalidate_all
(
self
):
self
.
check_thread
()
...
...
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