{"id":"gavinostler/zentag","name":"zentag","scope":"gavinostler","platform":"roblox","description":"Mirrored from the Wally registry.","version":"0.2.1","latest":"0.2.1","versions":["0.1.0","0.2.0","0.2.1"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"9b156da376b3e47f1596f1d052b10a5087542360a7ef3d67748f839fd9d7c364","likes":0,"downloads":0,"install":"forest install gavinostler/zentag","url":"https://forest.dev/p/roblox/gavinostler/zentag","files":"https://api.forest.dev/ai/package/roblox/gavinostler/zentag/files","readme":"# zentag\n[![](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT \"License: MIT\") [![](https://img.shields.io/github/issues/gavinostler/zentag.svg)](https://github.com/gavinostler/zentag/issues) [![](https://img.shields.io/github/issues-pr/gavinostler/zentag.svg)](https://github.com/gavinostler/zentag/issues) \n\nBasic tag related cacher that I wrote in a day. Could be used with [Promise](https://eryn.io/roblox-lua-promise/) for API calls... unsure of its performance.\n\n## Usage\n\n```luau\n-- Example with math.random()\nlocal getRandomNumberCache = zentag:unstableCache(function()\n    return math.random(1,4)\nend, {\"number\"})\n\nprint(getRandomNumberCache()) -- A random value\nprint(getRandomNumberCache()) -- A cached random value, same as the line directly above.\nzentag:revalidateTag(\"number\") -- Invalidates previous value.\nprint(getRandomNumberCache()) -- A new random value, differs from above.\nprint(getRandomNumberCache()) -- A cached random value, same as the line directly above.\nzentag:revalidateTag(\"cool\") -- Does not invalidate, will throw a warning unless disabled.\nprint(getRandomNumberCache()) -- A cached random value, same as the line two above.\n```\n\nUsing `zentag.unstableCache()`, you can cache the values of what is returned from a function when it is requested. Using the return value from the function, you can request the cached value as explained by the comments.\n\nYou can also assign multiple tags:\n```luau\n-- Example with math.random()\nlocal getRandomNumberCache = zentag:unstableCache(function()\n    return math.random(1,4)\nend, {\"number\", \"random\", \"interesting\"})\n\n-- Any of the below will invalidate the above cached value.\nzentag:revalidateTag(\"number\")\nzentag:revalidateTag(\"random\")\nzentag:revalidateTag(\"interesting\")\nzentag:revalidateMultipleTags({\"number\", \"random\"})\n```\n\nIf you attempt to revalidate a tag with no functions assigned to it, you will get something like this in the console:\n```\nThere was an attempt to invalidate a tag with no functions attached to it. This warning will not show up in production.\nTag: {tag}\n\nTo disable, run `zentag:disableTagWarning()` at runtime.\n```\n\nThis warning will disappear in production, but if you'd like to disable it, just run `zentag:disableTagWarning()` once.\n","readmeTruncated":false}