Skip to content

Commit 2953128

Browse files
authored
Merge pull request #13 from Microsoft/users/tedchamb/initial
update directory for cache files
2 parents 9d300c7 + 90d7a23 commit 2953128

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

vsts/vsts/_file_cache.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,24 @@ def _check_for_initial_load(self):
108108

109109

110110
def get_cache_dir():
111-
vsts_cache_dir = os.getenv('VSTS_CACHE_DIR', None) or os.path.expanduser(os.path.join('~', '.vsts', 'cache'))
111+
vsts_cache_dir = os.getenv('VSTS_CACHE_DIR', None) or os.path.expanduser(os.path.join('~', '.vsts', 'python-sdk',
112+
'cache'))
112113
if not os.path.exists(vsts_cache_dir):
113114
os.makedirs(vsts_cache_dir)
114115
return vsts_cache_dir
115116

116117

117-
def get_cache(name, max_age):
118-
file_name = os.path.join(get_cache_dir(), name + '.json')
118+
DEFAULT_MAX_AGE = 3600 * 12 # 12 hours
119+
DEFAULT_CACHE_DIR = get_cache_dir()
120+
121+
122+
def get_cache(name, max_age=DEFAULT_MAX_AGE, cache_dir=DEFAULT_CACHE_DIR):
123+
file_name = os.path.join(cache_dir, name + '.json')
119124
return FileCache(file_name, max_age)
120125

121126

122-
_DEFAULT_MAX_AGE = 3600 * 12 # 12 hours
123-
OPTIONS_CACHE = get_cache('options', _DEFAULT_MAX_AGE)
124-
RESOURCE_CACHE = get_cache('resources', _DEFAULT_MAX_AGE)
127+
OPTIONS_CACHE = get_cache('options')
128+
RESOURCE_CACHE = get_cache('resources')
125129

126130

127131
# Code below this point from azure-cli-core

0 commit comments

Comments
 (0)