瀏覽代碼

Added AWS instance types caching for better performance

Nuwan Goonasekera 7 年之前
父節點
當前提交
ddf6806382
共有 2 個文件被更改,包括 5 次插入1 次删除
  1. 3 0
      cloudbridge/cloud/providers/aws/services.py
  2. 2 1
      setup.py

+ 3 - 0
cloudbridge/cloud/providers/aws/services.py

@@ -4,6 +4,8 @@ import string
 
 from botocore.exceptions import ClientError
 
+import cachetools
+
 import requests
 
 import cloudbridge.cloud.base.helpers as cb_helpers
@@ -603,6 +605,7 @@ class AWSVMTypeService(BaseVMTypeService):
         super(AWSVMTypeService, self).__init__(provider)
 
     @property
+    @cachetools.cached(cachetools.TTLCache(maxsize=1, ttl=24*3600))
     def instance_data(self):
         """
         Fetch info about the available instances.

+ 2 - 1
setup.py

@@ -21,7 +21,8 @@ with open(os.path.join('cloudbridge', '__init__.py')) as f:
 REQS_BASE = [
     'bunch>=1.0.1',
     'six>=1.11',
-    'tenacity>=4.12.0,<=5.0'
+    'tenacity>=4.12.0,<=5.0',
+    'cachetools'
 ]
 REQS_AWS = ['boto3<1.8.0']
 # Install azure>=3.0.0 package to find which of the azure libraries listed