Skip to content

Commit c73988d

Browse files
frivoirejerome-quere
authored andcommitted
Add a short (ttl-based) cache to AccountAPI.get_quotas() (#24)
1 parent 30d3eb8 commit c73988d

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

CHANGES.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ChangeLog
44
`1.9.1 (unreleased) <https://github.com/scaleway/python-scaleway/compare/v1.9.0...develop>`_
55
--------------------------------------------------------------------------------------------
66

7-
* No changes yet.
7+
* Add a short (ttl-based) cache to ``AccountAPI.get_quotas()``
88

99
`1.9.0 (2019-07-03) <https://github.com/scaleway/python-scaleway/compare/v1.8.1...v1.9.0>`_
1010
--------------------------------------------------------------------------------------------

scaleway/apis/api_account.py

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# License at https://opensource.org/licenses/BSD-2-Clause
1111

1212
import slumber
13+
from cachetools.func import ttl_cache
1314
from six.moves import zip_longest
1415

1516
from . import API
@@ -179,6 +180,7 @@ def has_perm(self, service=None, name=None, resource=None,
179180
include_locked=include_locked)
180181
)
181182

183+
@ttl_cache(maxsize=10, ttl=60)
182184
def get_quotas(self, organization):
183185
""" Gets a list of quotas for the given organization.
184186
"""

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
PACKAGE_NAME = 'scaleway-sdk'
2828

2929
DEPENDENCIES = [
30+
'cachetools >= 3.1.1',
3031
'slumber >= 0.6.2',
3132
'six']
3233

0 commit comments

Comments
 (0)