# Path: djangoblog/utils.py
# def get_max_articleid_commentid():
# def get_sha256(str):
# def cache_decorator(expiration=3 * 60):
#     def wrapper(func):
#         def news(*args, **kwargs):
# def expire_view_cache(path, servername, serverport, key_prefix=None):
# def get_current_site():
#     def _convert_markdown(value):
#     def get_markdown_with_toc(value):
#     def get_markdown(value):
# def send_email(emailto, title, content):
# def generate_code() -> str:
# def parse_dict_to_url(dict):
# def get_blog_setting():
# def save_user_avatar(url):
# def delete_sidebar_cache():
# def delete_view_cache(prefix, keys):
# class CommonMarkdown:


from werobot.session import SessionStorage
from werobot.utils import json_loads, json_dumps
from djangoblog.utils import cache



class MemcacheStorage(SessionStorage):
    def __init__(self, prefix='ws_'):
        self.prefix = prefix
        self.cache = cache

    @property
    def is_available(self):
        value = "1"
        self.set('checkavaliable', value=value)
        return value == self.get('checkavaliable')

    def key_name(self, s):
        return '{prefix}{s}'.format(prefix=self.prefix, s=s)

    def get(self, id):
        id = self.key_name(id)

# Path: djangoblog/utils.py
# def get_max_articleid_commentid():
# def get_sha256(str):
# def cache_decorator(expiration=3 * 60):
#     def wrapper(func):
#         def news(*args, **kwargs):
# def expire_view_cache(path, servername, serverport, key_prefix=None):
# def get_current_site():
#     def _convert_markdown(value):
#     def get_markdown_with_toc(value):
#     def get_markdown(value):
# def send_email(emailto, title, content):
# def generate_code() -> str:
# def parse_dict_to_url(dict):
# def get_blog_setting():
# def save_user_avatar(url):
# def delete_sidebar_cache():
# def delete_view_cache(prefix, keys):
# class CommonMarkdown:


# Path: servermanager/MemcacheStorage.py
from werobot.session import SessionStorage
from werobot.utils import json_loads, json_dumps
from djangoblog.utils import cache




class MemcacheStorage(SessionStorage):
    def __init__(self, prefix='ws_'):
        self.prefix = prefix
        self.cache = cache

    @property
    def is_available(self):
        value = "1"
        self.set('checkavaliable', value=value)
        return value == self.get('checkavaliable')

    def key_name(self, s):
        return '{prefix}{s}'.format(prefix=self.prefix, s=s)

    def get(self, id):
        id = self.key_name(id)

        session_json = self.cache.get(id) or '{}'