Title: [FEATURE]: [ENHANCEMENT]: Add LRU (Least Recently Used) Cache implementation · Issue #304 · TheAlgorithms/TypeScript · GitHub
Open Graph Title: [FEATURE]: [ENHANCEMENT]: Add LRU (Least Recently Used) Cache implementation · Issue #304 · TheAlgorithms/TypeScript
X Title: [FEATURE]: [ENHANCEMENT]: Add LRU (Least Recently Used) Cache implementation · Issue #304 · TheAlgorithms/TypeScript
Description: Motivation Description Currently, the repository lacks a standardized implementation of an LRU (Least Recently Used) Cache. This is a fundamental data structure in computer science used for memory management and caching strategies. Propo...
Open Graph Description: Motivation Description Currently, the repository lacks a standardized implementation of an LRU (Least Recently Used) Cache. This is a fundamental data structure in computer science used for memory ...
X Description: Motivation Description Currently, the repository lacks a standardized implementation of an LRU (Least Recently Used) Cache. This is a fundamental data structure in computer science used for memory ...
Opengraph URL: https://github.com/TheAlgorithms/TypeScript/issues/304
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[FEATURE]: [ENHANCEMENT]: Add LRU (Least Recently Used) Cache implementation","articleBody":"### Motivation\n\n### Description\nCurrently, the repository lacks a standardized implementation of an **LRU (Least Recently Used) Cache**. This is a fundamental data structure in computer science used for memory management and caching strategies.\n\n### Proposed Solution\nI propose adding an LRU Cache implementation that achieves **O(1)** time complexity for both `get` and `put` operations by combining:\n1. **A Doubly Linked List:** To maintain the order of elements based on their usage.\n2. **A Hash Map (Map):** To provide fast access to nodes by their keys.\n\n### Implementation Details\n- **BaseCache (Abstract Class):** Defines the contract for cache implementations, demonstrating OOP abstraction.\n- **LRUCache (Concrete Class):** Extends `BaseCache` and manages the pointer logic for eviction and updates.\n- **Generics:** Supports any key-value types `\u003cK, V\u003e`.\n- **Unit Tests:** Comprehensive coverage for eviction, updates, and capacity constraints.\n\nI have already implemented this locally and would like to contribute it.\n\n### Examples\n\n_No response_\n\n### Possible workarounds\n\n_No response_","author":{"url":"https://github.com/MOHD-TAHA-KHAN","@type":"Person","name":"MOHD-TAHA-KHAN"},"datePublished":"2026-05-07T18:56:22.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/304/TypeScript/issues/304"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3411a77c-1409-33ca-6d2d-bb3b57f85c4f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AAD6:211BBA:118BC44:181E137:6A62DF04 |
| html-safe-nonce | 1ceb59cac3387d9f161861f5ae517fd84703b3ee0d2525164214d0ad23f99fa4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQUQ2OjIxMUJCQToxMThCQzQ0OjE4MUUxMzc6NkE2MkRGMDQiLCJ2aXNpdG9yX2lkIjoiMTQ1MDk5MTAwODM3MzQ2NDgzNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5eefb2b4d68a56c6ee0913d092dbe5f3bdf4c4876796c56c6ca346bba59c07d4 |
| hovercard-subject-tag | issue:4401242429 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/TheAlgorithms/TypeScript/304/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5815ee6121cb3986c730e402b028ebedf31d3e8eb4772d9cc08408823e90617e/TheAlgorithms/TypeScript/issues/304 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5815ee6121cb3986c730e402b028ebedf31d3e8eb4772d9cc08408823e90617e/TheAlgorithms/TypeScript/issues/304 |
| og:image:alt | Motivation Description Currently, the repository lacks a standardized implementation of an LRU (Least Recently Used) Cache. This is a fundamental data structure in computer science used for memory ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MOHD-TAHA-KHAN |
| hostname | github.com |
| expected-hostname | github.com |
| None | df33b1b61ee7b9a0af988199bfc3503c9c1acafb1f1d40e1f140ea7c84f890dd |
| turbo-cache-control | no-preview |
| go-import | github.com/TheAlgorithms/TypeScript git https://github.com/TheAlgorithms/TypeScript.git |
| octolytics-dimension-user_id | 20487725 |
| octolytics-dimension-user_login | TheAlgorithms |
| octolytics-dimension-repository_id | 532391729 |
| octolytics-dimension-repository_nwo | TheAlgorithms/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 532391729 |
| octolytics-dimension-repository_network_root_nwo | TheAlgorithms/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d41cd1bdb290013455c0ac430fa755621733f5eb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width