Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

phaux/kv_memoize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deno KvMemoize

deno doc

This library provides a utility function for memoization using Deno KV. It allows you to cache the results of expensive function calls and return the cached result when the same inputs occur again.

Example

import { kvMemoize } from "https://deno.land/x/kv_memoize/mod.ts";

const expensiveFunction = async (a: number, b: number) => {
  console.log("Running expensive function");
  return a + b;
};

const db = await Deno.openKv();

const memoizedFunction = kvMemoize(db, ["expensiveResults"], expensiveFunction);

console.log(await memoizedFunction(1, 2)); // Logs "Running expensive function" and prints 3
console.log(await memoizedFunction(1, 2)); // Prints 3

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published