Gabriel-Adrian Samfira пре 6 година
родитељ
комит
cfcff914ab
2 измењених фајлова са 29 додато и 0 уклоњено
  1. 27 0
      coriolis/cache.py
  2. 2 0
      requirements.txt

+ 27 - 0
coriolis/cache.py

@@ -0,0 +1,27 @@
+# Copyright 2019 Cloudbase Solutions Srl
+# All Rights Reserved.
+
+from coriolis import exception
+
+from oslo_config import cfg
+from oslo_cache import core as cache
+
+opts = [
+    cfg.BoolOpt('caching', default=False),
+    cfg.IntOpt('cache_time', default=7200),
+]
+
+CONF = cfg.CONF
+CONF.register_opts(opts)
+cache.configure(CONF)
+cache_region = cache.create_region()
+cache.configure_cache_region(CONF, cache_region)
+
+
+def get_cache_decorator(provider):
+    if type(provider) is not str or provider == "":
+        raise exception.CoriolisException(
+            "Invalid provider name")
+    MEMOIZE = cache.get_memoization_decorator(
+        CONF, cache_region, provider)
+    return MEMOIZE

+ 2 - 0
requirements.txt

@@ -3,6 +3,7 @@ keystoneauth1
 keystonemiddleware
 jsonschema
 PyMySQL
+oslo.cache
 oslo.concurrency
 oslo.config
 oslo.context>=2.19.1
@@ -27,6 +28,7 @@ python-barbicanclient
 python-swiftclient>=3.2
 git+https://github.com/cloudbase/pywinrm.git@requests#egg=pywinrm
 PyYAML
+redis
 requests
 mysqlclient
 schedule