Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sdake/pool
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/sdake/pool
- Owner: sdake
- License: apache-2.0
- Created: 2022-03-30T01:49:14.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-04-03T22:40:40.000Z (over 2 years ago)
- Last Synced: 2024-09-18T14:15:36.336Z (about 2 months ago)
- Language: Go
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ✨ pool is a Go generic bitmapped object cache.
[![Go Report Card](https://goreportcard.com/badge/github.com/sdake/pool)](https://goreportcard.com/report/github.com/sdake/pool)
[![GoDoc](https://godoc.org/github.com/sdake/pool?status.svg)](https://godoc.org/github.com/sdake/pool)## ❓ Why
- I wanted to learn Go generic syntax.
- I wanted to minimize the memory consumption of object storage.
- I wanted objects addressible by lines as well as handles.## 💡 Usage
You can import `pool` using:
```go
import (
"github.com/sdake/pool"
)
```Then create an object type, identify the number and length of the cache lines, and then create pool:
```go
// Define your custom object that will be stored in the cache lines.
type Object {
abra int
cadbra int
popcorn string
}// Define the cache lines sizes. The minimum size is 64 entries. Cache line sizes must be multiples of 64.
lineSize := []uint16{64, 64, 64, 64}// Create a pool object with 4 cache lines
pool := pool.New(Object, 4, lineSize...)
```Initialize an object and add to the pool in the third cache line:
```
ObjectS := Object{2, 1, "with butter please!"}
handle := pool.Put(ObjectS, 3)
```Remove that same object:
```
pool.Remove(handle)
```## 👤 Authors
- Steven Dake
## 💫 Show your support
I don't accept donations. So please give a ⭐️ if this project helped you!
## 📝 License
Copyright © [Steven Dake](https://github.com/sdake/). This project is [ASL2](./LICENSE) licensed.