403Webshell
Server IP : 35.80.110.71  /  Your IP : 216.73.216.221
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/fs/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/fs/lrucache.py
"""Least Recently Used cache mapping.
"""

from __future__ import absolute_import, unicode_literals

import typing

from collections import OrderedDict

_K = typing.TypeVar("_K")
_V = typing.TypeVar("_V")


class LRUCache(OrderedDict, typing.Generic[_K, _V]):
    """A dictionary-like container that stores a given maximum items.

    If an additional item is added when the LRUCache is full, the least
    recently used key is discarded to make room for the new item.

    """

    def __init__(self, cache_size):
        # type: (int) -> None
        """Create a new LRUCache with the given size."""
        self.cache_size = cache_size
        super(LRUCache, self).__init__()

    def __setitem__(self, key, value):
        # type: (_K, _V) -> None
        """Store a new views, potentially discarding an old value."""
        if key not in self:
            if len(self) >= self.cache_size:
                self.popitem(last=False)
        OrderedDict.__setitem__(self, key, value)

    def __getitem__(self, key):
        # type: (_K) -> _V
        """Get the item, but also makes it most recent."""
        _super = typing.cast(OrderedDict, super(LRUCache, self))
        value = _super.__getitem__(key)
        _super.__delitem__(key)
        _super.__setitem__(key, value)
        return value

Youez - 2016 - github.com/yon3zu
LinuXploit