Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nisarg2061/goache
Goache - A Go-based LRU Cache implementation using a Linked List to showcase data structure and algorithm applications
https://github.com/nisarg2061/goache
dsa go golang linked-list
Last synced: 2 days ago
JSON representation
Goache - A Go-based LRU Cache implementation using a Linked List to showcase data structure and algorithm applications
- Host: GitHub
- URL: https://github.com/nisarg2061/goache
- Owner: Nisarg2061
- License: bsd-3-clause
- Created: 2024-08-16T15:49:47.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-08-29T20:18:16.000Z (3 months ago)
- Last Synced: 2024-08-29T22:23:54.327Z (3 months ago)
- Topics: dsa, go, golang, linked-list
- Language: Go
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Goache
## Description
Goache is a simple implementation of a Least Recently Used (LRU) Cache in Go, utilizing a Linked List data structure.
This project is designed to demonstrate the practical application of data structures and algorithms in building a cache system.## Concepts Used
- Data Structures and Algorithms (DSA)
- Linked Lists
- Caching Mechanisms## Objectives
- LRU Cache: Implement a cache that follows the Least Recently Used (LRU) eviction policy.
- Item Reordering: On cache hit, the item is moved to the front of the list (head).
- Order Maintenance: Maintain the order of items based on their usage.
- Efficient Operations: Deletion occurs at the tail (least recently used), while addition occurs at the head (most recently used).## Installation
To install Goache, use `go get`:
```
go get github.com/Nisarg2061/Goache
```## Example Usage
Let's start by using the Goache cache system in a simple Go application:
```go
package mainimport "github.com/Nisarg2061/Goache/Cache"
func main() {
c := Cache.NewCache(5)
c.Check("String")
c.Display()
}
```
- Here, we create a new cache instance with a maximum capacity of 5 items. The `NewCache` function initializes the cache and sets the limit on the number of items it can hold. Once the limit is reached, the least recently used item will be evicted to make space for new items.
- The `Check` method moves the item to the front of the list, marking it as the most recently used. If the item already exists in the cache, it updates its position.
- The `Display` method outputs the current state of the cache, showing its contents and the order of items. This helps you verify that the cache is functioning as expected and provides a way to inspect what’s currently stored in the cache.
## License
BSD licensed. See the LICENSE file for details.