Skip to content

Commit

Permalink
cachew: switch to using appdirs/user cache directory instead of /tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
karlicoss committed Mar 20, 2021
1 parent 0aecf1d commit 161ce25
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@
"{flink('cachew.settings')} exposes some parameters that allow you to control `cachew` behaviour:\n",
"- `ENABLE`: set to `False` if you want to disable caching for without removing the decorators (useful for testing and debugging).\n",
" You can also use {flink('cachew.extra.disabled_cachew')} context manager to do it temporarily.\n",
"- `DEFAULT_CACHEW_DIR`: override to set a different base directory.\n",
"- `DEFAULT_CACHEW_DIR`: override to set a different base directory. The default is the \"user cache directory\" (see [appdirs docs](https://github.com/ActiveState/appdirs#some-example-output)).\n",
"- `THROW_ON_ERROR`: by default, cachew is defensive and simply attemps to cause the original function on caching issues.\n",
" Set to `True` to catch errors earlier.\n",
"\n",
Expand Down Expand Up @@ -463,10 +463,10 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.5"
},
"name": "README.ipynb"
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
description = 'Easy sqlite-backed persistent cache for dataclasses'

install_requires = [
'sqlalchemy',
'appdirs' , # default cache dir
'sqlalchemy', # cache DB interaction
]


Expand Down
7 changes: 4 additions & 3 deletions src/cachew/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
import warnings


import sqlalchemy # type: ignore
import appdirs # type: ignore[import]

import sqlalchemy # type: ignore[import]
from sqlalchemy import Column, Table, event


Expand Down Expand Up @@ -65,8 +67,7 @@ class settings:
'''
ENABLE: bool = True

# switch to appdirs and using user cache dir?
DEFAULT_CACHEW_DIR: PathIsh = Path(tempfile.gettempdir()) / 'cachew'
DEFAULT_CACHEW_DIR: PathIsh = Path(appdirs.user_cache_dir('cachew'))

'''
Set to true if you want to fail early. Otherwise falls back to non-cached version
Expand Down

0 comments on commit 161ce25

Please sign in to comment.