亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cache.py

?? Mod_python is an Apache module that embeds the Python interpreter within the server. With mod_python
?? PY
字號:
# # Copyright 2004 Apache Software Foundation  #  # Licensed under the Apache License, Version 2.0 (the "License"); you # may not use this file except in compliance with the License.  You # may obtain a copy of the License at # #      http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied.  See the License for the specific language governing # permissions and limitations under the License. # # Originally developed by Gregory Trubetskoy. #  # This was donated by Nicolas Lehuen, and also posted to the Python Cookbook # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302997 #  # $Id: cache.py 408048 2006-05-20 17:44:51Z jgallacher $from os import statfrom time import time, mktimefrom rfc822 import parsedatefrom calendar import timegmimport urllib2import reimport weakrefimport newtry:    from threading import Lockexcept ImportError:    from dummy_threading import LockNOT_INITIALIZED = object()class Entry(object):    """ A cache entry, mostly an internal object. """    def __init__(self, key):        object.__init__(self)        self._key=key        self._value=NOT_INITIALIZED        self._lock=Lock()class Cache(object):    """ An abstract, multi-threaded cache object. """        def __init__(self, max_size=0):        """ Builds a cache with a limit of max_size entries.            If this limit is exceeded, the Least Recently Used entry is discarded.            if max_size==0, the cache is unbounded (no LRU rule is applied).        """        object.__init__(self)        self._maxsize=max_size        self._dict={}        self._lock=Lock()                # Header of the access list        if self._maxsize:            self._head=Entry(None)            self._head._previous=self._head            self._head._next=self._head    def __setitem__(self, name, value):        """ Populates the cache with a given name and value. """        key = self.key(name)                entry = self._get_entry(key)                entry._lock.acquire()        try:            self._pack(entry,value)            self.commit()        finally:            entry._lock.release()    def __getitem__(self, name):        """ Gets a value from the cache, builds it if required.        """        return self._checkitem(name)[2]    def __delitem__(self, name):        self._lock.acquire()        try:            key = self.key(name)            del self._dict[key]        finally:            self._lock.release()    def _get_entry(self,key):        self._lock.acquire()        try:            entry = self._dict.get(key)            if not entry:                entry = Entry(key)                self._dict[key]=entry                if self._maxsize:                    entry._next = entry._previous = None                    self._access(entry)                    self._checklru()            elif self._maxsize:                self._access(entry)            return entry        finally:            self._lock.release()    def _checkitem(self, name):        """ Gets a value from the cache, builds it if required.            Returns a tuple is_new, key, value, entry.            If is_new is True, the result had to be rebuilt.        """        key = self.key(name)                entry = self._get_entry(key)        entry._lock.acquire()        try:            value = self._unpack(entry)            is_new = False            if value is NOT_INITIALIZED:                opened = self.check(key, name, entry)                value = self.build(key, name, opened, entry)                is_new = True                self._pack(entry, value)                self.commit()            else:                opened = self.check(key, name, entry)                if opened is not None:                    value = self.build(key, name, opened, entry)                    is_new = True                    self._pack(entry, value)                    self.commit()            return is_new, key, value, entry        finally:            entry._lock.release()    def mru(self):        """ Returns the Most Recently Used key """        if self._maxsize:            self._lock.acquire()            try:                return self._head._previous._key            finally:                self._lock.release()        else:            return None    def lru(self):        """ Returns the Least Recently Used key """        if self._maxsize:            self._lock.acquire()            try:                return self._head._next._key            finally:                self._lock.release()        else:            return None    def key(self, name):        """ Override this method to extract a key from the name passed to the [] operator """        return name    def commit(self):        """ Override this method if you want to do something each time the underlying dictionary is modified (e.g. make it persistent). """        pass    def clear(self):        """ Clears the cache """        self._lock.acquire()        try:            self._dict.clear()            if self._maxsize:                self._head._next=self._head                self._head._previous=self._head        finally:            self._lock.release()    def check(self, key, name, entry):        """ Override this method to check whether the entry with the given name is stale. Return None if it is fresh            or an opened resource if it is stale. The object returned will be passed to the 'build' method as the 'opened' parameter.            Use the 'entry' parameter to store meta-data if required. Don't worry about multiple threads accessing the same name,            as this method is properly isolated.        """        return None    def build(self, key, name, opened, entry):        """ Build the cached value with the given name from the given opened resource. Use entry to obtain or store meta-data if needed.             Don't worry about multiple threads accessing the same name, as this method is properly isolated.        """        raise NotImplementedError()               def _access(self, entry):        " Internal use only, must be invoked within a cache lock. Updates the access list. """        if entry._next is not self._head:            if entry._previous is not None:                # remove the entry from the access list                entry._previous._next=entry._next                entry._next._previous=entry._previous            # insert the entry at the end of the access list            entry._previous=self._head._previous            entry._previous._next=entry            entry._next=self._head            entry._next._previous=entry            if self._head._next is self._head:                self._head._next=entry    def _checklru(self):        " Internal use only, must be invoked within a cache lock. Removes the LRU entry if needed. """        if len(self._dict)>self._maxsize:            lru=self._head._next            lru._previous._next=lru._next            lru._next._previous=lru._previous            del self._dict[lru._key]    def _pack(self, entry, value):        """ Store the value in the entry. """        entry._value=value    def _unpack(self, entry):        """ Recover the value from the entry, returns NOT_INITIALIZED if it is not OK. """        return entry._valueclass WeakCache(Cache):    """ This cache holds weak references to the values it stores. Whenever a value is not longer        normally referenced, it is removed from the cache. Useful for sharing the result of long        computations but letting them go as soon as they are not needed by anybody.    """            def _pack(self, entry, value):        entry._value=weakref.ref(value, lambda ref: self.__delitem__(entry._key))            def _unpack(self, entry):        if entry._value is NOT_INITIALIZED:            return NOT_INITIALIZED                    value = entry._value()        if value is None:            return NOT_INITIALIZED        else:            return valueclass FileCache(Cache):    """ A file cache. Returns the content of the files as a string, given their filename.        Whenever the files are modified (according to their modification time) the cache is updated.        Override the build method to obtain more interesting behaviour.    """    def __init__(self, max_size=0, mode='rb'):        Cache.__init__(self, max_size)        self.mode=mode        def check(self, key, name, entry):        timestamp = stat(key).st_mtime         if entry._value is NOT_INITIALIZED:            entry._timestamp = timestamp            return file(key, self.mode)        else:            if entry._timestamp != timestamp:                entry._timestamp = timestamp                return file(key, self.mode)            else:                return None    def build(self, key, name, opened, entry):        """ Return the content of the file as a string. Override this for better behaviour. """        try:            return opened.read()        finally:            opened.close()def parseRFC822Time(t):    return mktime(parsedate(t))re_max_age=re.compile('max-age\s*=\s*(\d+)', re.I)class HTTPEntity(object):    def __init__(self, entity, metadata):        self.entity=entity        self.metadata=metadata        def __repr__(self):        return 'HTTPEntity(%s, %s)'%(repr(self.entity), self.metadata)            def __str__(self):        return self.entityclass HTTPCache(Cache):    """ An HTTP cache. Returns the entity found at the given URL.        Uses Expires, ETag and Last-Modified headers to minimize bandwidth usage.        Partial Cache-Control support (only max-age is supported).    """    def check(self, key, name, entry):        request = urllib2.Request(key)                try:            if time()<entry._expires:                return None        except AttributeError:            pass                    try:            header, value = entry._validator            request.headers[header]=value        except AttributeError:            pass        opened = None        try:            opened = urllib2.urlopen(request)            headers = opened.info()            # expiration handling                        expiration = False            try:                match = re_max_age.match(headers['cache-control'])                if match:                    entry._expires=time()+int(match.group(1))                    expiration = True            except (KeyError, ValueError):                pass            if not expiration:                try:                    date = parseRFC822Time(headers['date'])                    expires = parseRFC822Time(headers['expires'])                    entry._expires = time()+(expires-date)                    expiration = True                except KeyError:                    pass                        # validator handling            validation = False            try:                entry._validator='If-None-Match', headers['etag']                validation = True            except KeyError:                pass            if not validation:                try:                    entry._validator='If-Modified-Since', headers['last-modified']                except KeyError:                    pass            return opened        except urllib2.HTTPError, error:            if opened: opened.close()            if error.code==304:                return None            else:                raise error    def build(self, key, name, opened, entry):        try:            return HTTPEntity(opened.read(), dict(opened.info()))        finally:            opened.close()re_not_word = re.compile(r'\W+')class ModuleCache(FileCache):    """ A module cache. Give it a file name, it returns a module        which results from the execution of the Python script it contains.        This module is not inserted into sys.modules.    """    def __init__(self, max_size=0):        FileCache.__init__(self, max_size, 'r')        def build(self, key, name, opened, entry):        try:            module = new.module(re_not_word.sub('_',key))            module.__file__ = key            exec opened in module.__dict__            return module        finally:            opened.close()class HttpModuleCache(HTTPCache):    """ A module cache. Give it an HTTP URL, it returns a module        which results from the execution of the Python script it contains.        This module is not inserted into sys.modules.    """    def __init__(self, max_size=0):        HTTPCache.__init__(self, max_size)        def build(self, key, name, opened, entry):        try:            module = new.module(re_not_word.sub('_',key))            module.__file__ = key            text = opened.read().replace('\r\n', '\n')            code = compile(text, name, 'exec')            exec code in module.__dict__            return module        finally:            opened.close()class FunctionCache(Cache):    def __init__(self, function, max_size=0):        Cache.__init__(self, max_size)        self.function=function        def __call__(self, *args, **kw):        if kw:            # a dict is not hashable so we build a tuple of (key, value) pairs            kw = tuple(kw.iteritems())            return self[args, kw]        else:            return self[args, ()]        def build(self, key, name, opened, entry):        args, kw = key        return self.function(*args, **dict(kw))

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩电影在线免费看| 精品少妇一区二区三区免费观看| 国产精品久久久久久久久免费桃花| 国产成人日日夜夜| 中文字幕乱码一区二区免费| 国产不卡在线播放| 亚洲人精品午夜| 精品视频在线免费| 美女精品一区二区| 国产日韩精品一区| 91丨九色porny丨蝌蚪| 一区二区三区免费| 欧美一区二区三区视频免费播放 | 亚洲精品日韩专区silk| 欧美在线观看视频一区二区三区| 亚洲成av人在线观看| 精品久久久久99| 不卡电影免费在线播放一区| 伊人一区二区三区| 日韩欧美成人激情| av一区二区三区| 爽好多水快深点欧美视频| 久久久综合网站| 在线观看日韩精品| 精品在线观看视频| 亚洲精品乱码久久久久久日本蜜臀| 欧美日韩激情一区二区| 国产精品一区在线观看你懂的| 亚洲欧美日韩在线播放| 日韩欧美在线综合网| av一区二区三区在线| 日本aⅴ免费视频一区二区三区| 午夜成人免费电影| 国产精品免费视频网站| 制服丝袜av成人在线看| 丁香婷婷综合激情五月色| 亚洲一区日韩精品中文字幕| 精品国产乱码久久久久久蜜臀| 97久久精品人人爽人人爽蜜臀| 日本成人在线网站| 亚洲欧美日韩一区二区| 久久美女高清视频 | 欧美一二三区精品| 波波电影院一区二区三区| 美女视频黄a大片欧美| 一区二区三区四区在线播放 | 日韩国产欧美在线视频| 国产精品久久777777| 日韩视频一区二区| 在线观看亚洲精品视频| av一区二区三区| 国产揄拍国内精品对白| 日本欧美在线观看| 亚洲一区二区三区四区在线| 国产精品久久久久久久岛一牛影视| 日韩欧美在线综合网| 欧美色图一区二区三区| 99久久国产免费看| 成人高清免费观看| 国产精品456露脸| 久久国产精品99久久人人澡| 偷拍与自拍一区| 亚洲综合视频在线观看| 日韩一区日韩二区| 国产精品天美传媒| 国产欧美一区二区精品久导航| 日韩精品一区二区三区中文精品| 欧美精品久久久久久久多人混战| 91国在线观看| 欧美在线不卡视频| 欧美在线视频不卡| 欧美亚洲丝袜传媒另类| 欧美日韩免费一区二区三区| 在线看不卡av| 欧美理论电影在线| 欧美一区午夜精品| 精品欧美乱码久久久久久| 欧美电视剧在线观看完整版| 欧美电影免费提供在线观看| 精品国产亚洲在线| 国产日韩欧美精品一区| 国产精品久久三| 亚洲精品久久7777| 亚洲九九爱视频| 午夜视黄欧洲亚洲| 久久国产视频网| 国产经典欧美精品| 91在线观看视频| 欧美在线视频全部完| 91精品国产综合久久婷婷香蕉| 69av一区二区三区| 欧美一区二区在线不卡| 日韩一区二区电影| 国产香蕉久久精品综合网| 五月天激情综合| 久久97超碰国产精品超碰| 国产成人日日夜夜| 色婷婷av久久久久久久| 欧美精品777| 久久综合国产精品| 中文字幕制服丝袜一区二区三区| 亚洲激情校园春色| 久久精品噜噜噜成人av农村| 国产一区二区三区免费播放| 99视频精品免费视频| 欧美无乱码久久久免费午夜一区| 91精品国产综合久久香蕉麻豆| 久久久午夜电影| 亚洲自拍另类综合| 国产综合色视频| 91福利国产精品| 日韩精品自拍偷拍| 亚洲码国产岛国毛片在线| 奇米一区二区三区av| 懂色中文一区二区在线播放| 欧美日韩亚洲综合一区二区三区 | 欧美三级资源在线| 久久亚洲精精品中文字幕早川悠里| 亚洲视频小说图片| 美女脱光内衣内裤视频久久影院| 成人激情黄色小说| 在线播放91灌醉迷j高跟美女| 国产视频在线观看一区二区三区 | 一区二区三区在线观看欧美| 日韩成人av影视| 91丝袜国产在线播放| 337p日本欧洲亚洲大胆精品| 亚洲与欧洲av电影| 国产福利一区二区三区在线视频| 欧美日韩一级片网站| ...xxx性欧美| 国产呦精品一区二区三区网站| 在线观看成人免费视频| 国产精品网曝门| 国产一区二区0| 欧美一区二区免费视频| 夜夜夜精品看看| 成人开心网精品视频| 日韩一级高清毛片| 亚洲综合色网站| av一二三不卡影片| 久久精品视频一区二区| 日本怡春院一区二区| 91久久精品一区二区二区| 国产亚洲欧美日韩在线一区| 蜜桃视频在线一区| 欧美日韩久久不卡| 亚洲一区中文日韩| 一本大道久久a久久精二百| 国内精品写真在线观看| 国产精品美女久久久久aⅴ| 日韩精品一区二区三区swag| 成人高清视频免费观看| 91精品婷婷国产综合久久性色| 成人免费在线视频观看| 国产99久久精品| 久久久久久久国产精品影院| 精品在线播放免费| 日韩欧美高清在线| 麻豆精品蜜桃视频网站| 91麻豆精品久久久久蜜臀| 亚洲成av人片在线| 3d成人动漫网站| 亚洲福利电影网| 中文字幕一区二区三区不卡| 国产精品一区不卡| 久久精品视频网| 国产99久久久精品| 中文字幕欧美一| 91无套直看片红桃| 一区二区三区在线免费观看| 一本色道**综合亚洲精品蜜桃冫 | 不卡的av电影在线观看| 中文字幕乱码日本亚洲一区二区| 国产不卡视频一区二区三区| 国产日韩欧美亚洲| 99热在这里有精品免费| 亚洲图片欧美激情| 欧美综合久久久| 亚洲一区二区三区三| 欧美精选在线播放| 国产一区二区三区免费看 | 亚洲欧洲日本在线| 日本韩国欧美一区二区三区| 一区二区三区不卡视频在线观看| 欧美性受xxxx| 久久国产欧美日韩精品| 国产欧美精品区一区二区三区| 99热这里都是精品| 亚洲123区在线观看| 欧美成人免费网站| 成人精品gif动图一区| 亚洲午夜激情网页| 欧美α欧美αv大片| 国产精品一区二区果冻传媒| 自拍偷拍国产精品| 欧美疯狂做受xxxx富婆| 高清不卡一二三区| 亚洲成人你懂的| 久久蜜桃av一区二区天堂|