Giter Club home page Giter Club logo

oyzem's Introduction

=========================================== oyzem - Simple Memoization Library for Go

License Open Source

How to Install

Install oyzem using go get:

go get -u github.com/simplyYan/oyzem

Introduction

oyzem 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

package main

import (
	"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)
}
package main

import (
	"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 Contribute

Contributions 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.

oyzem's People

Contributors

simplyyan avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.