403Webshell
Server IP : 123.56.80.60  /  Your IP : 216.73.216.78
Web Server : Apache/2.4.54 (Win32) OpenSSL/1.1.1s PHP/7.4.33 mod_fcgid/2.3.10-dev
System : Windows NT iZhx3sob14hnz7Z 10.0 build 14393 (Windows Server 2016) i586
User : SYSTEM ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Program Files/python/Lib/site-packages/cachelib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Program Files/python/Lib/site-packages/cachelib/uwsgi.py
# -*- coding: utf-8 -*-
import platform
try:
    import cPickle as pickle
except ImportError:  # pragma: no cover
    import pickle

from cachelib.base import BaseCache


class UWSGICache(BaseCache):
    """ Implements the cache using uWSGI's caching framework.

    .. note::
        This class cannot be used when running under PyPy, because the uWSGI
        API implementation for PyPy is lacking the needed functionality.

    :param default_timeout: The default timeout in seconds.
    :param cache: The name of the caching instance to connect to, for
        example: mycache@localhost:3031, defaults to an empty string, which
        means uWSGI will cache in the local instance. If the cache is in the
        same instance as the werkzeug app, you only have to provide the name of
        the cache.
    """
    def __init__(self, default_timeout=300, cache=''):
        BaseCache.__init__(self, default_timeout)

        if platform.python_implementation() == 'PyPy':
            raise RuntimeError("uWSGI caching does not work under PyPy, see "
                               "the docs for more details.")

        try:
            import uwsgi
            self._uwsgi = uwsgi
        except ImportError:
            raise RuntimeError("uWSGI could not be imported, are you "
                               "running under uWSGI?")

        self.cache = cache

    def get(self, key):
        rv = self._uwsgi.cache_get(key, self.cache)
        if rv is None:
            return
        return pickle.loads(rv)

    def delete(self, key):
        return self._uwsgi.cache_del(key, self.cache)

    def set(self, key, value, timeout=None):
        return self._uwsgi.cache_update(key, pickle.dumps(value),
                                        self._normalize_timeout(timeout),
                                        self.cache)

    def add(self, key, value, timeout=None):
        return self._uwsgi.cache_set(key, pickle.dumps(value),
                                     self._normalize_timeout(timeout),
                                     self.cache)

    def clear(self):
        return self._uwsgi.cache_clear(self.cache)

    def has(self, key):
        return self._uwsgi.cache_exists(key, self.cache) is not None

Youez - 2016 - github.com/yon3zu
LinuXploit