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
85287429
Unverified
Commit
85287429
authored
1 year ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
CacheDict will now accept time-like strings
parent
96d18e25
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
satella/coding/structures/dictionaries/cache_dict.py
+4
-5
4 additions, 5 deletions
satella/coding/structures/dictionaries/cache_dict.py
with
4 additions
and
5 deletions
satella/coding/structures/dictionaries/cache_dict.py
+
4
−
5
View file @
85287429
...
...
@@ -3,6 +3,7 @@ import time
import
typing
as
tp
from
concurrent.futures
import
ThreadPoolExecutor
,
Executor
,
Future
from
satella.coding.decorators.decorators
import
short_none
from
satella.coding.recast_exceptions
import
silence_excs
from
satella.coding.structures.lru
import
LRU
from
satella.coding.typing
import
K
,
V
,
NoArgCallable
...
...
@@ -91,8 +92,8 @@ class CacheDict(tp.Mapping[K, V]):
default_value_factory
:
tp
.
Optional
[
NoArgCallable
[
V
]]
=
None
):
self
.
stale_interval
=
parse_time_string
(
stale_interval
)
self
.
expiration_interval
=
parse_time_string
(
expiration_interval
)
assert
stale_interval
<=
expiration_interval
,
'
Stale interval may not be larger
'
\
'
than expiration interval!
'
assert
self
.
stale_interval
<=
self
.
expiration_interval
,
'
Stale interval may not be larger
'
\
'
than expiration interval!
'
self
.
default_value_factory
=
default_value_factory
self
.
value_getter
=
value_getter
if
value_getter_executor
is
None
:
...
...
@@ -102,9 +103,7 @@ class CacheDict(tp.Mapping[K, V]):
self
.
timestamp_data
=
{}
# type: tp.Dict[K, float]
self
.
cache_missed
=
set
()
# type: tp.Set[K]
self
.
cache_failures
=
cache_failures_interval
is
not
None
if
cache_failures_interval
is
not
None
:
cache_failures_interval
=
parse_time_string
(
cache_failures_interval
)
self
.
cache_failures_interval
=
cache_failures_interval
self
.
cache_failures_interval
=
short_none
(
parse_time_string
)(
cache_failures_interval
)
self
.
time_getter
=
time_getter
def
get_value_block
(
self
,
key
:
K
)
->
V
:
...
...
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