# Path: cherrypy/_cpcompat.py
#     def ntob(n, encoding='ISO-8859-1'):
#     def ntou(n, encoding='ISO-8859-1'):
#     def tonative(n, encoding='ISO-8859-1'):
#     def ntob(n, encoding='ISO-8859-1'):
#     def ntou(n, encoding='ISO-8859-1'):
#     def tonative(n, encoding='ISO-8859-1'):
# def assert_native(n):
# def base64_decode(n, encoding='ISO-8859-1'):
#     def sorted(i):
#     def reversed(x):
#     def get_daemon(t):
#     def set_daemon(t, val):
#     def get_daemon(t):
#     def set_daemon(t, val):
#     def HTTPDate(timeval=None):
#     def unquote_qs(atom, encoding, errors='strict'):
#     def unquote_qs(atom, encoding, errors='strict'):
#         def json_decode(s):
#         def _json_encode(s):
#         def json_encode(value):
#     def random20():
#     def random20():
#     def next(i):
#     def __get_daemon(self):
#     def __set_daemon(self, daemon):
# class SetDaemonProperty:


import datetime
import sys
import threading
import time
import cherrypy
from cherrypy.lib import cptools, httputil
from cherrypy._cpcompat import copyitems, ntob, set_daemon, sorted, Event
        if variant is not None:
            self.tot_hist += 1
        return variant

    def put(self, variant, size):
        """Store the current variant in the cache."""
        request = cherrypy.serving.request
        response = cherrypy.serving.response

        uri = cherrypy.url(qs=request.query_string)
        uricache = self.store.get(uri)
        if uricache is None:
            uricache = AntiStampedeCache()
            uricache.selecting_headers = [
                e.value for e in response.headers.elements('Vary')]
            self.store[uri] = uricache

        if len(self.store) < self.maxobjects:
            total_size = self.cursize + size

            # checks if there's space for the object
            if (size < self.maxobj_size and total_size < self.maxsize):
                # add to the expirations list
                expiration_time = response.time + self.delay
                bucket = self.expirations.setdefault(expiration_time, [])
                bucket.append((size, uri, uricache.selecting_headers))

                # add to the cache
                header_values = [request.headers.get(h, '')
                                 for h in uricache.selecting_headers]

# Path: cherrypy/_cpcompat.py
#     def ntob(n, encoding='ISO-8859-1'):
#     def ntou(n, encoding='ISO-8859-1'):
#     def tonative(n, encoding='ISO-8859-1'):
#     def ntob(n, encoding='ISO-8859-1'):
#     def ntou(n, encoding='ISO-8859-1'):
#     def tonative(n, encoding='ISO-8859-1'):
# def assert_native(n):
# def base64_decode(n, encoding='ISO-8859-1'):
#     def sorted(i):
#     def reversed(x):
#     def get_daemon(t):
#     def set_daemon(t, val):
#     def get_daemon(t):
#     def set_daemon(t, val):
#     def HTTPDate(timeval=None):
#     def unquote_qs(atom, encoding, errors='strict'):
#     def unquote_qs(atom, encoding, errors='strict'):
#         def json_decode(s):
#         def _json_encode(s):
#         def json_encode(value):
#     def random20():
#     def random20():
#     def next(i):
#     def __get_daemon(self):
#     def __set_daemon(self, daemon):
# class SetDaemonProperty:


# Path: cherrypy/lib/caching.py
import datetime
import sys
import threading
import time
import cherrypy
from cherrypy.lib import cptools, httputil
from cherrypy._cpcompat import copyitems, ntob, set_daemon, sorted, Event

        if variant is not None:
            self.tot_hist += 1
        return variant

    def put(self, variant, size):
        """Store the current variant in the cache."""
        request = cherrypy.serving.request
        response = cherrypy.serving.response

        uri = cherrypy.url(qs=request.query_string)
        uricache = self.store.get(uri)
        if uricache is None:
            uricache = AntiStampedeCache()
            uricache.selecting_headers = [
                e.value for e in response.headers.elements('Vary')]
            self.store[uri] = uricache

        if len(self.store) < self.maxobjects:
            total_size = self.cursize + size

            # checks if there's space for the object
            if (size < self.maxobj_size and total_size < self.maxsize):
                # add to the expirations list
                expiration_time = response.time + self.delay
                bucket = self.expirations.setdefault(expiration_time, [])
                bucket.append((size, uri, uricache.selecting_headers))

                # add to the cache
                header_values = [request.headers.get(h, '')
                                 for h in uricache.selecting_headers]

                uricache[tuple(sorted(header_values))] = variant