{"id":17964790,"url":"https://github.com/processone/cache_tab","last_synced_at":"2025-04-07T08:19:48.479Z","repository":{"id":57481682,"uuid":"9811205","full_name":"processone/cache_tab","owner":"processone","description":"In-memory cache Erlang / Elixir library","archived":false,"fork":false,"pushed_at":"2024-06-27T08:56:49.000Z","size":165,"stargazers_count":45,"open_issues_count":3,"forks_count":23,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-31T06:05:51.855Z","etag":null,"topics":["cache","erlang"],"latest_commit_sha":null,"homepage":"http://www.ejabberd.im","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/processone.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-05-02T10:50:43.000Z","updated_at":"2025-03-14T22:56:31.000Z","dependencies_parsed_at":"2025-01-15T03:54:28.785Z","dependency_job_id":"fd2745e2-a2ea-41af-a93b-260267e006bd","html_url":"https://github.com/processone/cache_tab","commit_stats":{"total_commits":134,"total_committers":11,"mean_commits":"12.181818181818182","dds":0.6791044776119404,"last_synced_commit":"28125d7034fe3a7c08767ea39b6f11306072b58d"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/processone%2Fcache_tab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/processone%2Fcache_tab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/processone%2Fcache_tab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/processone%2Fcache_tab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/processone","download_url":"https://codeload.github.com/processone/cache_tab/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247615385,"owners_count":20967184,"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-10-29T12:08:40.546Z","updated_at":"2025-04-07T08:19:48.457Z","avatar_url":"https://github.com/processone.png","language":"Erlang","readme":"# In-memory cache application for Erlang / Elixir apps\n\n[![CI](https://github.com/processone/cache_tab/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/processone/cache_tab/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/processone/cache_tab/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/processone/cache_tab?branch=master)\n[![Hex version](https://img.shields.io/hexpm/v/cache_tab.svg \"Hex version\")](https://hex.pm/packages/cache_tab)\n\n`cache_tab` application is intended to proxy back-end operations for\nKey-Value insert, lookup and delete and maintain a cache of those\nKey-Values in-memory, to save back-end operations.\n\nOperations are intended to be atomic between back-end and cache\ntables.\n\nThe lifetime of the cache object and the max size of the cache can be\ndefined as table parameters to limit the size of the in-memory tables.\n\n## Building\n\n`cache_tab` application can be build as follow:\n\n    make\n\nIt is a rebar-compatible OTP application. Alternatively, you can build\nit with rebar:\n\n    rebar get-deps compile\n\n## Usage\n\nYou can start the application with the command:\n\n```\n$ erl -pa ebin -pa deps/*/ebin\nErlang/OTP 18 [erts-7.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]\n\nEshell V7.1  (abort with ^G)\n1\u003e application:start(cache_tab).\n```\n\nThen, you can create a table for a specific type of data to cache. You\ncan create several tables to separate your cached data. The following\ncommand will create a table named `tab_name`:\n\n```\ncache_tab:new(tab_name, [{life_time, Seconds}, {max_size, N}]).\n```\n\nThe optional `life_time` option is used to define cache entry\nexpiration. The optional `max_size` option is used to limit number of\nentries to add in cache.\n\nYou can insert data into the cache with:\n\n```\ncache_tab:insert(tab_name, \u003c\u003c\"key\"\u003e\u003e, \u003c\u003c\"value\"\u003e\u003e, fun() -\u003e do_something() end).\n```\n\nCache inserts are designed to be able to act as a proxy to backend\ninsert. That's the purpose of the fun called as last parameter\n(`do_something`). Return of the fun is ignored, but if it crashes,\ncache will not be stored.  If value did not change compared to\nprevious insert, the fun will not be called, saving possibly unneeded\nwrite operations\n\nYou can also lookup data from the cache:\n\n```\ncache_tab:lookup(tab_name, \u003c\u003c\"key\"\u003e\u003e, fun() -\u003e read_value_if_not_cached() end).\n```\n\nThe fun in last parameter is used to read and cache the value from\nyour back-end if it is not already in cache.\n\nIt is expected to return either `{ok, Value}` or `error`.\n\nYou can delete entries from back-end and cache with command:\n\n\n```\ncache_tab:delete(tab_name, \u003c\u003c\"key\"\u003e\u003e, fun() -\u003e do_something() end),\n```\n\nInfo command will report about the hits / misses to help you tune your\ncache size / lifetime parameters:\n\n```\ncache_tab:info(tab_name, Info).\n```\n\nInfo parameter can be: `size`, `ratio` or `all`.\n\n## Development\n\n### Test\n\n#### Unit test\n\nYou can run eunit test with the command:\n\n    $ make test\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprocessone%2Fcache_tab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprocessone%2Fcache_tab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprocessone%2Fcache_tab/lists"}