{"id":15056400,"url":"https://github.com/nitrogen/nitro_cache","last_synced_at":"2025-04-10T04:07:19.279Z","repository":{"id":56824459,"uuid":"312929549","full_name":"nitrogen/nitro_cache","owner":"nitrogen","description":"Caching Server for Nitrogen Web Framework","archived":false,"fork":false,"pushed_at":"2023-10-07T21:13:13.000Z","size":1283,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T05:24:47.343Z","etag":null,"topics":["cache","erlang"],"latest_commit_sha":null,"homepage":"https://nitrogenproject.com","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nitrogen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-11-15T00:39:49.000Z","updated_at":"2023-09-14T12:15:44.000Z","dependencies_parsed_at":"2022-09-01T13:10:54.937Z","dependency_job_id":null,"html_url":"https://github.com/nitrogen/nitro_cache","commit_stats":{"total_commits":46,"total_committers":7,"mean_commits":6.571428571428571,"dds":"0.32608695652173914","last_synced_commit":"c92d1328acbd0a1ace6b6e85f2d9760e92ffda9a"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrogen%2Fnitro_cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrogen%2Fnitro_cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrogen%2Fnitro_cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nitrogen%2Fnitro_cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nitrogen","download_url":"https://codeload.github.com/nitrogen/nitro_cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247993677,"owners_count":21030043,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","erlang"],"created_at":"2024-09-24T21:50:50.176Z","updated_at":"2025-04-10T04:07:19.255Z","avatar_url":"https://github.com/nitrogen.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NitroCache\n\nNitroCache is a fork of [simple_cache](https://github.com/marcelog/simple_cache)\nmodified specifically for the needs of integration with the [Nitrogen Web\nFramework](http://nitrogenproject.com).\n\nThe updated code now has a separate process to handle the expirations, which is\na regular `gen_server`. To start it, just do:\n\n```erlang\nnitro_cache_expirer:start_link().\n```\n\n## Create a cache\n\n```erlang\nnitro_cache:init(my_cache_name).\n```\n\n## Getting a key\n\nThe following call will lookup **my_key** in the cache named **my_cache_name**, and on\na MISS will call the given **fun**, caching its result for **3600000** milliseconds.\n\n```erlang\nnitro_cache:get(my_cache_name, 3600000, my_key, fun() -\u003e\n\tio:format(\"This fun will be called on a cache miss~n\"),\n\ttimer:sleep(5000)\n\tthis_value_will_be_cached\nend).\n```\n\n## Flushing the cache\n\n```erlang\n    nitro_cache:flush(my_cache_name).\n```\n\n## Flushing a key\n\n```erlang\n    nitro_cache:flush(my_cache_name, my_key).\n```\n\n## Changes:\n\n### Version 0.5.0\n\n+ The mutex server has been pulled out of NitroCache and renamed to\n  [Mutagen](https://github.com/nitrogen/mutagen).\n\n### Version 0.4.1\n\n+ Fixed a bug where the mutex wouldn't free if the provided function crashed.\n\n### Version 0.4.0\n\n+ Renamed to NitroCache to avoid a name clash (simple_cache is already taken\n  on hex.pm)\n+ Requesting a key from a bucket if it has not yet been initialized will\n  automatically instantiate that bucket.\n+ NitroCache introduced a mutex system to prevent recalculating the same\n  slow-calculating key when multiple requests come in at same time.  When the\n  key's value is calculated, it will return the result to all the waiting\n  requests.\n+ Added a `cache_exists/1` function.\n+ Added a `set/4` function.\n+ Converted to rebar3\n\n### Earlier Version Modifications from the [original](https://github.com/marcelog/simple_cache)\n\n* Requesting a key from a bucket if it has not yet been initialized will\n  automatically instantiate that bucket.\n* Added a `cache_exists/1` function.\n* Added a `set/4` function.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitrogen%2Fnitro_cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnitrogen%2Fnitro_cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnitrogen%2Fnitro_cache/lists"}