Skip to content

Commit

Permalink
Mongodb backend (#214)
Browse files Browse the repository at this point in the history
* mongodb-backend

* update ci

* use mongo docker action

* use pymongo instead of mongoengine

* fix typing error

* use mongo bulk operations to improve efficiency

* Update CHANGES.rst

* allow providing mongodb client

* update documentation

* move pymongo import to class constructor

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* test mongodb cache index

* recompile requirements

* add change log

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: northernSage <[email protected]>
  • Loading branch information
3 people authored Feb 11, 2024
1 parent bf1f8fd commit b76abc3
Show file tree
Hide file tree
Showing 13 changed files with 333 additions and 111 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ jobs:
sudo apt-get install libmemcached-dev memcached redis-server
- name: setup dynamodb-local
uses: rrainn/[email protected]
- name: Start MongoDB
uses: wbari/[email protected]
with:
mongoDBVersion: 'latest'
- name: update pip
run: |
pip install -U wheel
Expand Down
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Version 0.12.0
Unreleased

- ``RedisCache`` now supports callables as keys
- Added ``MongoDB`` as a cache backend

Version 0.11.0
--------------
Expand Down Expand Up @@ -38,7 +39,6 @@ Released 2023-01-22
- Improve error message when ``FileSystemCache`` methods are called with non-str keys. :pr:`170`
- Added ``DynamoDb`` as a cache backend :pr:`209`


Version 0.9.0
-------------

Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ from Werkzeug.
memcached
uwsgi
dynamodb
mongodb

.. toctree::
:maxdepth: 2
Expand Down
7 changes: 7 additions & 0 deletions docs/mongodb.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MongoDb Backend
===============

.. automodule:: cachelib.mongodb
:members:
:undoc-members:
:show-inheritance:
127 changes: 56 additions & 71 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,78 +1,74 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile requirements/dev.in
#
alabaster==0.7.12
alabaster==0.7.16
# via sphinx
async-timeout==4.0.3
# via redis
babel==2.9.1
babel==2.14.0
# via sphinx
boto3==1.34.38
# via -r tests.in
botocore==1.34.38
boto3==1.34.39
# via -r requirements/tests.in
botocore==1.34.39
# via
# boto3
# s3transfer
build==0.8.0
build==1.0.3
# via pip-tools
cachetools==5.3.2
# via tox
certifi==2023.7.22
certifi==2024.2.2
# via requests
cffi==1.15.1
cffi==1.16.0
# via cryptography
cfgv==3.3.1
cfgv==3.4.0
# via pre-commit
chardet==5.2.0
# via tox
charset-normalizer==2.0.7
charset-normalizer==3.3.2
# via requests
click==8.0.3
click==8.1.7
# via pip-tools
colorama==0.4.6
# via tox
cryptography==42.0.0
cryptography==42.0.2
# via
# types-pyopenssl
# types-redis
distlib==0.3.7
distlib==0.3.8
# via virtualenv
docutils==0.18.1
dnspython==2.5.0
# via pymongo
docutils==0.20.1
# via
# sphinx
# sphinx-tabs
exceptiongroup==1.2.0
# via pytest
filelock==3.13.1
# via
# tox
# virtualenv
identify==2.3.3
identify==2.5.34
# via pre-commit
idna==3.3
idna==3.6
# via requests
imagesize==1.4.1
# via sphinx
importlib-metadata==6.8.0
# via sphinx
iniconfig==1.1.1
iniconfig==2.0.0
# via pytest
jinja2==3.1.3
# via sphinx
jmespath==1.0.1
# via
# boto3
# botocore
markupsafe==2.0.1
markupsafe==2.1.5
# via jinja2
mypy==1.8.0
# via -r typing.in
# via -r requirements/typing.in
mypy-extensions==1.0.0
# via mypy
nodeenv==1.6.0
nodeenv==1.8.0
# via pre-commit
packaging==23.2
# via
Expand All @@ -83,111 +79,100 @@ packaging==23.2
# sphinx
# tox
pallets-sphinx-themes==2.1.1
# via -r docs.in
pep517==0.12.0
# via build
# via -r requirements/docs.in
pip-tools==7.3.0
# via -r dev.in
# via -r requirements/dev.in
platformdirs==4.2.0
# via
# tox
# virtualenv
pluggy==1.3.0
pluggy==1.4.0
# via
# pytest
# tox
pre-commit==3.6.0
# via -r dev.in
psutil==5.8.0
pre-commit==3.6.1
# via -r requirements/dev.in
psutil==5.9.8
# via pytest-xprocess
pycparser==2.21
# via cffi
pygments==2.15.0
pygments==2.17.2
# via
# sphinx
# sphinx-tabs
pylibmc==1.6.3
# via -r tests.in
# via -r requirements/tests.in
pymongo==4.6.1
# via -r requirements/tests.in
pyproject-api==1.6.1
# via tox
pyproject-hooks==1.0.0
# via build
pytest==8.0.0
# via
# -r tests.in
# -r requirements/tests.in
# pytest-xprocess
pytest-xprocess==0.23.0
# via -r tests.in
# via -r requirements/tests.in
python-dateutil==2.8.2
# via botocore
pytz==2021.3
# via babel
pyyaml==6.0
pyyaml==6.0.1
# via pre-commit
redis==5.0.1
# via -r tests.in
# via -r requirements/tests.in
requests==2.31.0
# via sphinx
s3transfer==0.10.0
# via boto3
six==1.16.0
# via python-dateutil
snowballstemmer==2.1.0
snowballstemmer==2.2.0
# via sphinx
sphinx==7.2.6
# via
# -r docs.in
# -r requirements/docs.in
# pallets-sphinx-themes
# sphinx-issues
# sphinx-tabs
# sphinxcontrib-log-cabinet
sphinx-issues==4.0.0
# via -r docs.in
# via -r requirements/docs.in
sphinx-tabs==3.4.5
# via -r docs.in
sphinxcontrib-applehelp==1.0.2
# via -r requirements/docs.in
sphinxcontrib-applehelp==1.0.8
# via sphinx
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-devhelp==1.0.6
# via sphinx
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-htmlhelp==2.0.5
# via sphinx
sphinxcontrib-jsmath==1.0.1
# via sphinx
sphinxcontrib-log-cabinet==1.0.1
# via -r docs.in
sphinxcontrib-qthelp==1.0.3
# via -r requirements/docs.in
sphinxcontrib-qthelp==1.0.7
# via sphinx
sphinxcontrib-serializinghtml==1.1.10
# via sphinx
tomli==2.0.1
# via
# build
# mypy
# pep517
# pip-tools
# pyproject-api
# pytest
# tox
tox==4.12.1
# via -r dev.in
types-pyopenssl==23.0.0.2
# via -r requirements/dev.in
types-pyopenssl==24.0.0.20240130
# via types-redis
types-redis==4.6.0.20240106
# via -r typing.in
typing-extensions==4.8.0
# via -r requirements/typing.in
typing-extensions==4.9.0
# via mypy
urllib3==1.26.18
urllib3==2.0.7
# via
# botocore
# requests
uwsgi==2.0.23
# via -r tests.in
uwsgi==2.0.24
# via -r requirements/tests.in
virtualenv==20.25.0
# via
# pre-commit
# tox
wheel==0.38.1
wheel==0.42.0
# via pip-tools
zipp==3.17.0
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# pip
Expand Down
16 changes: 6 additions & 10 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile requirements/docs.in
Expand All @@ -20,8 +20,6 @@ idna==3.3
# via requests
imagesize==1.4.1
# via sphinx
importlib-metadata==7.0.1
# via sphinx
jinja2==3.1.3
# via sphinx
markupsafe==2.0.1
Expand All @@ -31,7 +29,7 @@ packaging==21.2
# pallets-sphinx-themes
# sphinx
pallets-sphinx-themes==2.1.1
# via -r docs.in
# via -r requirements/docs.in
pygments==2.15.0
# via
# sphinx
Expand All @@ -46,15 +44,15 @@ snowballstemmer==2.1.0
# via sphinx
sphinx==7.2.6
# via
# -r docs.in
# -r requirements/docs.in
# pallets-sphinx-themes
# sphinx-issues
# sphinx-tabs
# sphinxcontrib-log-cabinet
sphinx-issues==4.0.0
# via -r docs.in
# via -r requirements/docs.in
sphinx-tabs==3.4.5
# via -r docs.in
# via -r requirements/docs.in
sphinxcontrib-applehelp==1.0.2
# via sphinx
sphinxcontrib-devhelp==1.0.2
Expand All @@ -64,12 +62,10 @@ sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
# via sphinx
sphinxcontrib-log-cabinet==1.0.1
# via -r docs.in
# via -r requirements/docs.in
sphinxcontrib-qthelp==1.0.3
# via sphinx
sphinxcontrib-serializinghtml==1.1.10
# via sphinx
urllib3==1.26.18
# via requests
zipp==3.17.0
# via importlib-metadata
1 change: 1 addition & 0 deletions requirements/tests.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ redis
uwsgi
pytest-xprocess
boto3
pymongo
Loading

0 comments on commit b76abc3

Please sign in to comment.