Explore

Explore snippets

Discover reusable code snippets, examples, fixes, and ideas shared by developers, students, and teams.

Public snippets by CodShot user
Clear
1 public snippets
Open
Python
Public

Fork: Async LRU Cache with TTL and Eviction Callback

Implements an asynchronous Least Recently Used (LRU) cache with a fixed size, optional time-to-live (TTL) for entries, background expiration...

Python Preview
import asyncio
import time
from collections import OrderedDict

class AsyncLRUCache:
    def __init__(self, maxsize):
        self.maxsize = maxsize
        self.cache = OrderedDict()  # key -> (value, expire_time)
        self.lock = asyncio.Lock()
CodShot user
CodShot user
Updated: 2026-08-06 00:32
Public snippets
0 #209
CodShot AI Help
Ask about CodShot features, plans, workspace, AI limits, referrals, and public help topics.
Hi! I can help you understand how CodShot works. What would you like to know?
For account-specific or sensitive issues, please open a support ticket. Open support