https://github.com/simplyyan/oyzem
memoizing has never been easier
https://github.com/simplyyan/oyzem
framework go go-framework go-lib go-library go-package golang memoization memoization-library memoize memoize-decorator perfomance
Last synced: about 2 months ago
JSON representation
memoizing has never been easier
- Host: GitHub
- URL: https://github.com/simplyyan/oyzem
- Owner: simplyYan
- License: bsd-3-clause
- Created: 2024-01-30T13:01:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-27T18:03:27.000Z (9 months ago)
- Last Synced: 2025-02-07T06:22:48.522Z (3 months ago)
- Topics: framework, go, go-framework, go-lib, go-library, go-package, golang, memoization, memoization-library, memoize, memoize-decorator, perfomance
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
===========================================
oyzem - Simple Memoization Library for Go
===========================================[](https://opensource.org/licenses/BSD-3-Clause)
[](https://opensource.org/)## How to Install
Install `oyzem` using `go get`:
```bash
go get -u github.com/simplyYan/oyzem
```
## Introductionoyzem is a lightweight and easy-to-use Go library for memoization, providing a simple mechanism to cache function results and improve performance.
Features- Easy: Simple API for memoizing functions.
- Fast: Efficient caching using a mutex for thread safety.
- Lightweight: Minimalistic design with a focus on simplicity.
- Objective: Aims to provide a clear and straightforward memoization solution.## License
oyzem is distributed under the BSD-3-Clause License. See the LICENSE file for details.
## Examples
```go
package mainimport (
"fmt"
"github.com/simplyYan/oyzem"
)func main() {
// Create a new Memoizer instance
memoizer := oyzem.New()// Memoize a function
memoizedFn, _ := memoizer.Memoize(func(a, b int) int {
fmt.Println("Performing calculation...")
return a + b
})// Run the memoized function
result, _ := memoizer.Run(memoizedFn, 2, 3)
fmt.Println("Result:", result)
}
```
```go
package mainimport (
"fmt"
"github.com/simplyYan/oyzem"
)func main() {
// Create a new Memoizer instance
memoizer := oyzem.New()// Memoize a function
memoizedFn, _ := memoizer.Memoize(func(a, b int) int {
fmt.Println("Performing calculation...")
return a + b
})// Run the memoized function
result1, _ := memoizer.Run(memoizedFn, 2, 3)
fmt.Println("Result 1:", result1)// Run the memoized function again (result obtained from the cache)
result2, _ := memoizer.Run(memoizedFn, 2, 3)
fmt.Println("Result 2 (from cache):", result2)// Run the memoized function with different arguments
result3, _ := memoizer.Run(memoizedFn, 4, 5)
fmt.Println("Result 3:", result3)
}```
## How to ContributeContributions to oyzem are welcome! If you want to add, fix, or improve features, follow these steps:
1. Fork the repository on GitHub.
2. Clone your forked repository: git clone https://github.com/your-username/oyzem.git.
3. Create a new branch: git checkout -b feature-name.
4. Make your changes and commit: git commit -m "Description of changes".
5. Push your branch to GitHub: git push origin feature-name.
6. Open a pull request on the official oyzem repository.