# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x
# 
# Path: aredis/exceptions.py
# class SerializeError(CacheError):
#     pass
# 
# class CompressError(CacheError):
#     pass


import hashlib
import time
import zlib
    import ujson as json
    import json
from aredis.utils import b
from aredis.exceptions import (SerializeError,
                               CompressError)

try:
except ImportError:



class IdentityGenerator:
    """
    Generator of identity for unique key,
    you may overwrite it to meet your customize requirements.
    """

    TEMPLATE = '{app}:{key}:{content}'

    def __init__(self, app, encoding='utf-8'):
        self.app = app
        self.encoding = encoding

    def _trans_type(self, content):
        if isinstance(content, str):
            content = content.encode(self.encoding)
        elif isinstance(content, int):
            content = b(str(content))
        elif isinstance(content, float):

# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x
# 
# Path: aredis/exceptions.py
# class SerializeError(CacheError):
#     pass
# 
# class CompressError(CacheError):
#     pass


# Path: aredis/cache.py
import hashlib
import time
import zlib
    import ujson as json
    import json
from aredis.utils import b
from aredis.exceptions import (SerializeError,
                               CompressError)


try:
except ImportError:



class IdentityGenerator:
    """
    Generator of identity for unique key,
    you may overwrite it to meet your customize requirements.
    """

    TEMPLATE = '{app}:{key}:{content}'

    def __init__(self, app, encoding='utf-8'):
        self.app = app
        self.encoding = encoding

    def _trans_type(self, content):
        if isinstance(content, str):
            content = content.encode(self.encoding)
        elif isinstance(content, int):
            content = b(str(content))
        elif isinstance(content, float):

            content = b(repr(content))