403Webshell
Server IP : 192.64.118.117  /  Your IP : 3.16.48.173
Web Server : LiteSpeed
System : Linux premium56.web-hosting.com 4.18.0-513.24.1.lve.1.el8.x86_64 #1 SMP Thu May 9 15:10:09 UTC 2024 x86_64
User : thecgapy ( 1160)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/opt/hc_python/lib64/python3.12/site-packages/sentry_sdk/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/opt/hc_python/lib64/python3.12/site-packages/sentry_sdk/_lru_cache.py
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from typing import Any


_SENTINEL = object()


class LRUCache:
    def __init__(self, max_size):
        # type: (int) -> None
        if max_size <= 0:
            raise AssertionError(f"invalid max_size: {max_size}")
        self.max_size = max_size
        self._data = {}  # type: dict[Any, Any]
        self.hits = self.misses = 0
        self.full = False

    def set(self, key, value):
        # type: (Any, Any) -> None
        current = self._data.pop(key, _SENTINEL)
        if current is not _SENTINEL:
            self._data[key] = value
        elif self.full:
            self._data.pop(next(iter(self._data)))
            self._data[key] = value
        else:
            self._data[key] = value
        self.full = len(self._data) >= self.max_size

    def get(self, key, default=None):
        # type: (Any, Any) -> Any
        try:
            ret = self._data.pop(key)
        except KeyError:
            self.misses += 1
            ret = default
        else:
            self.hits += 1
            self._data[key] = ret

        return ret

    def get_all(self):
        # type: () -> list[tuple[Any, Any]]
        return list(self._data.items())

Youez - 2016 - github.com/yon3zu
LinuXploit