Unverified Commit 5a98f7e4 authored by Jintao Lin's avatar Jintao Lin Committed by GitHub
Browse files

enalbe memcached support in PetrelBackend (#341)

parent 5f611bbb
......@@ -60,16 +60,17 @@ class PetrelBackend(BaseStorageBackend):
path_mapping (dict|None): path mapping dict from local path to Petrel
path. When `path_mapping={'src': 'dst'}`, `src` in `filepath` will
be replaced by `dst`. Default: None.
enable_mc (bool): whether to enable memcached support. Default: True.
"""
def __init__(self, path_mapping=None):
def __init__(self, path_mapping=None, enable_mc=True):
try:
from petrel_client import client
except ImportError:
raise ImportError('Please install petrel_client to enable '
'PetrelBackend.')
self._client = client.Client()
self._client = client.Client(enable_mc=enable_mc)
assert isinstance(path_mapping, dict) or path_mapping is None
self.path_mapping = path_mapping
......
......@@ -15,6 +15,9 @@ sys.modules['mc'] = MagicMock()
class MockS3Client(object):
def __init__(self, enable_mc=True):
self.enable_mc = enable_mc
def Get(self, filepath):
with open(filepath, 'rb') as f:
content = f.read()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment