def __init__(self, size_min=4800, size_max=5200, fs=None): # A mapping from key to handler self.cache = LRUCache(size_min, size_max, automatic=False) self.fs = fs or vfs
] for name in names: if getattr(self, name) != getattr(other, name): return False return True def __str__(self): output = ['"%s"' % self.value] if self.path is not None: output.append('$Path="%s"' % self.path) if self.domain is not None: output.append('$Domain="%s"' % self.domain) return '; '.join(output) CACHE_COOKIES = LRUCache(200) class CookieDataType(DataType): """ TODO: Performances can be improved For instant we use cache """ @staticmethod def decode(data): base_data = data if CACHE_COOKIES.get(base_data): CACHE_COOKIES.touch(base_data) return CACHE_COOKIES[base_data] # Parse the cookie string parameters = [] while data:
# (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # Import from itools from itools.core import LRUCache from generic import GenericDataType from registry import get_scheme cache = LRUCache(200) def get_reference(reference): """Returns a URI reference of the good type from the given string. """ # Hit if reference in cache: return cache[reference] # Miss if ':' in reference: scheme_name, scheme_specifics = reference.split(':', 1) scheme = get_scheme(scheme_name) else: scheme = GenericDataType