Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
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
RadioObservatory
LOFAR
Commits
5659dec6
Commit
5659dec6
authored
6 years ago
by
Jorrit Schaap
Browse files
Options
Downloads
Patches
Plain Diff
SW-448
: keep results for non existing paths in cache
parent
c860fd7c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SAS/DataManagement/StorageQueryService/cache.py
+17
-17
17 additions, 17 deletions
SAS/DataManagement/StorageQueryService/cache.py
with
17 additions
and
17 deletions
SAS/DataManagement/StorageQueryService/cache.py
+
17
−
17
View file @
5659dec6
...
@@ -128,7 +128,7 @@ class CacheManager:
...
@@ -128,7 +128,7 @@ class CacheManager:
# Furthermore, once a deeper level du results is stored in the memory cache, then it is also available for fast lookup.
# Furthermore, once a deeper level du results is stored in the memory cache, then it is also available for fast lookup.
# We just don't store these deep levels on disk.
# We just don't store these deep levels on disk.
sub_cache
=
{
path
:
du_result
for
path
,
du_result
in
self
.
_cache
[
'
path_du_results
'
].
items
()
sub_cache
=
{
path
:
du_result
for
path
,
du_result
in
self
.
_cache
[
'
path_du_results
'
].
items
()
if
self
.
getDepthToProjectsDir
(
path
)
<=
1
}
if
self
.
getDepthToProjectsDir
(
path
)
<=
1
and
du_result
.
get
(
'
found
'
)
}
cache_str
=
str
(
sub_cache
)
cache_str
=
str
(
sub_cache
)
with
open
(
tmp_path
,
'
w
'
)
as
file
:
with
open
(
tmp_path
,
'
w
'
)
as
file
:
...
@@ -154,24 +154,24 @@ class CacheManager:
...
@@ -154,24 +154,24 @@ class CacheManager:
if
path
in
path_cache
:
if
path
in
path_cache
:
otdb_id
=
du_result
.
get
(
'
otdb_id
'
)
otdb_id
=
du_result
.
get
(
'
otdb_id
'
)
if
du_result
[
'
found
'
]:
if
not
path
in
path_cache
or
path_cache
[
path
][
'
disk_usage
'
]
!=
du_result
[
'
disk_usage
'
]:
if
not
path
in
path_cache
or
path_cache
[
path
][
'
disk_usage
'
]
!=
du_result
[
'
disk_usage
'
]:
# update the cache entry, even when no du result found,
# update the cache entry, even when no du result found,
# cause that will save disk queries next time.
# cause that will save disk queries next time.
logger
.
info
(
'
updating cache entry: %s
'
,
du_result
)
logger
.
info
(
'
updating cache entry: %s
'
,
du_result
)
path_cache
[
path
]
=
du_result
path_cache
[
path
]
=
du_result
path_cache
[
path
][
'
cache_timestamp
'
]
=
datetime
.
datetime
.
utcnow
()
if
otdb_id
!=
None
:
path_cache
[
path
][
'
needs_update
'
]
=
False
otdb_id2
path_cache
[
otdb_id
]
=
path
if
otdb_id
!=
None
:
if
not
du_result
[
'
found
'
]:
otdb_id2path_cache
[
otdb_id
]
=
path
# even when the du for the path is not found,
else
:
# keep a copy in the cache for fast lookup by clients
if
path
in
path_cache
:
# Make sure the size is 0
# no need to keep unknown path in cache
du_result
[
'
disk_usage
'
]
=
0
del
path_cache
[
path
]
du_result
[
'
disk_usage_readable
'
]
=
humanreadablesize
(
0
)
if
otdb_id
!=
None
and
otdb_id
in
otdb_id2path_cache
:
del
otdb_id2path_cache
[
otdb_id
]
path_cache
[
path
][
'
cache_timestamp
'
]
=
datetime
.
datetime
.
utcnow
()
path_cache
[
path
][
'
needs_update
'
]
=
False
self
.
_writeCacheToDisk
()
self
.
_writeCacheToDisk
()
...
...
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