Forest Logo
search
package_2

memoize

By @cometahn1042f

Roblox

Mirrored

Memoize

Memoize is a high-performance function memoization library for Luau. It caches evaluation results using weak-key tables to optimize recursive or expensive pure functions without creating permanent memory references.

Documentation Index

  • API Reference: Functional exports (memoize, memoize1, memoize2, memoize3).
  • Architecture & Design: Trie-based weak caching model and nil support.
  • Performance & Memory Profile: Cache lookup overhead and garbage collection mechanics.
  • Failure Modes & Exception Guarantees: Non-pure function side effects and primitive key caveats.
  • Executable Examples: Code samples for single and multi-argument memoization.

Quick Start

local Memoize = require(path.to.Memoize)

local function expensiveCalculation(a: number, b: number): number
    return a ^ b
end

local memoized = Memoize.memoize2(expensiveCalculation)
print(memoized(2, 10)) -- Computes 1024
print(memoized(2, 10)) -- Cached return 1024

Package Details

Install command (Click to copy)


Version

0.1.2

License

MIT

check_circle

Safe for commercial use

Automated license review — not legal advice.