Skip to content

Instantly share code, notes, and snippets.

View mrcrowl's full-sized avatar

mrcrowl

  • New Zealand
View GitHub Profile
@dherges
dherges / lru-cache.ts
Last active November 17, 2025 20:56
Simple LRU Cache in TypeScript
class LruCache<T> {
private values: Map<string, T> = new Map<string, T>();
private maxEntries: number = 20;
public get(key: string): T {
const hasKey = this.values.has(key);
let entry: T;
if (hasKey) {
// peek the entry, re-insert for LRU strategy