Skip to content

Commit f9e4bee

Browse files
committed
AlyxClient.rest_cache_dir property allows users to change location of REST response cache
1 parent 6cb0082 commit f9e4bee

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ This version makes some performance improvements and supports local mode eid2pid
99
- update cache tables with calls to OneAlyx.eid2pid, pid2eid, eid2path, path2eid, get_details
1010
- OneAlyx.eid2pid and pid2eid support local mode queries so long as the insertions table exists
1111

12+
### Added
13+
14+
- AlyxClient.rest_cache_dir property allows users to change location of REST response cache
15+
1216
## [3.2.1]
1317

1418
### Modified

one/webclient.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def wrapper_decorator(alyx_client, *args, expires=None, clobber=False, **kwargs)
109109
response will not be used on subsequent calls. If None, the default expiry is applied.
110110
clobber : bool
111111
If True any existing cached response is overwritten.
112-
**kwargs
112+
kwargs
113113
Keyword arguments for applying to wrapped function.
114114
115115
Returns
@@ -123,7 +123,7 @@ def wrapper_decorator(alyx_client, *args, expires=None, clobber=False, **kwargs)
123123
if args[0].__name__ != mode and mode != '*':
124124
return method(alyx_client, *args, **kwargs)
125125
# Check cache
126-
rest_cache = alyx_client.cache_dir.joinpath('.rest')
126+
rest_cache = alyx_client.rest_cache_dir
127127
sha1 = hashlib.sha1()
128128
sha1.update(bytes(args[1], 'utf-8'))
129129
name = sha1.hexdigest()
@@ -577,6 +577,7 @@ def __init__(self, base_url=None, username=None, password=None,
577577
# The default expiry is overridden by the `expires` kwarg. If False, the caching is
578578
# turned off.
579579
self.default_expiry = timedelta(minutes=5)
580+
self.rest_cache_dir = self.cache_dir.joinpath('.rest')
580581
self.cache_mode = cache_rest
581582
self._obj_id = id(self)
582583

@@ -1368,5 +1369,5 @@ def json_field_delete(
13681369

13691370
def clear_rest_cache(self):
13701371
"""Clear all REST response cache files for the base url."""
1371-
for file in self.cache_dir.joinpath('.rest').glob('*'):
1372+
for file in self.rest_cache_dir.glob('*'):
13721373
file.unlink()

0 commit comments

Comments
 (0)