Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
e3a58ad4
Commit
e3a58ad4
authored
5 years ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
optimize CacheDict
parent
3fdc496d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
satella/__init__.py
+1
-1
1 addition, 1 deletion
satella/__init__.py
satella/coding/structures/dictionaries/cache_dict.py
+8
-3
8 additions, 3 deletions
satella/coding/structures/dictionaries/cache_dict.py
with
10 additions
and
4 deletions
CHANGELOG.md
+
1
−
0
View file @
e3a58ad4
# v2.8.20
*
optimization in
`CacheDict`
This diff is collapsed.
Click to expand it.
satella/__init__.py
+
1
−
1
View file @
e3a58ad4
__version__
=
'
2.8.20_a
2
'
__version__
=
'
2.8.20_a
3
'
This diff is collapsed.
Click to expand it.
satella/coding/structures/dictionaries/cache_dict.py
+
8
−
3
View file @
e3a58ad4
...
...
@@ -67,6 +67,8 @@ class CacheDict(tp.Mapping[K, V]):
def
get_value_block
(
self
,
key
:
K
)
->
V
:
"""
Get a value using value_getter. Block until it
'
s available. Store it into the cache.
:raises KeyError: the value is not present at all
"""
future
=
self
.
value_getter_executor
.
submit
(
self
.
value_getter
,
key
)
try
:
...
...
@@ -79,10 +81,13 @@ class CacheDict(tp.Mapping[K, V]):
return
value
def
_on_failure
(
self
,
key
:
K
)
->
None
:
"""
Called internally when a KeyError occurs
"""
"""
Called internally when a KeyError occurs.
It is expected that try_delete(key) will be always called before
"""
# at this point the data is deleted by try_delete(key)
if
self
.
cache_failures
:
with
silence_excs
(
KeyError
):
del
self
.
data
[
key
]
self
.
cache_missed
.
add
(
key
)
self
.
timestamp_data
[
key
]
=
self
.
time_getter
()
...
...
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