{"id":13776245,"url":"https://github.com/openresty/lua-resty-shdict-simple","last_synced_at":"2025-05-11T10:30:52.708Z","repository":{"id":136300291,"uuid":"71943421","full_name":"openresty/lua-resty-shdict-simple","owner":"openresty","description":"Simple applicaton-oriented interface to the OpenResty shared dictionary API","archived":false,"fork":false,"pushed_at":"2023-08-07T14:43:29.000Z","size":15,"stargazers_count":32,"open_issues_count":0,"forks_count":11,"subscribers_count":18,"default_branch":"master","last_synced_at":"2024-02-13T20:33:53.910Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openresty.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-10-25T22:13:54.000Z","updated_at":"2023-08-07T14:43:34.000Z","dependencies_parsed_at":"2023-07-24T07:01:00.490Z","dependency_job_id":"1df45a59-c2a8-46da-b192-779896aef1b0","html_url":"https://github.com/openresty/lua-resty-shdict-simple","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openresty%2Flua-resty-shdict-simple","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openresty%2Flua-resty-shdict-simple/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openresty%2Flua-resty-shdict-simple/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openresty%2Flua-resty-shdict-simple/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openresty","download_url":"https://codeload.github.com/openresty/lua-resty-shdict-simple/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253551495,"owners_count":21926303,"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":[],"created_at":"2024-08-03T18:00:20.480Z","updated_at":"2025-05-11T10:30:52.384Z","avatar_url":"https://github.com/openresty.png","language":"Perl","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"Name\n====\n\nlua-resty-shdict-simple - Simple application-oriented interface to OpenResty's shared dictionary API\n\nTable of Contents\n=================\n\n* [Name](#name)\n* [Synopsis](#synopsis)\n* [TODO](#todo)\n* [Author](#author)\n* [Copyright and License](#copyright-and-license)\n* [See Also](#see-also)\n\nSynopsis\n========\n\n```lua\nlocal shdict_simple = require \"resty.shdict.simple\"\n\nlocal function dlog(ctx, ...)\n    ngx.log(ngx.DEBUG, \"my app: \", ...)\nend\n\nlocal function error_log(ctx, ...)\n    ngx.log(ngx.ERR, \"my app: \", ...)\nend\n\nlocal pos_ttl = 20000  -- in ms\nlocal neg_ttl = 10000  -- in ms\n\nlocal my_shdict_set, my_shdict_get\n                  = shdict_simple.gen_shdict_methods{\n                       dict_name = \"my_lua_shared_dict_name\",\n                       debug_logger = dlog,\n                       error_logger = error_log,\n                       positive_ttl = pos_ttl,\n                       negative_ttl = neg_ttl,\n                       max_tries = 10, -- default is 1\n                    }\n\n-- on hot code paths:\n\nlocal ctx = ngx.ctx\n\nlocal key = \"name\"\nlocal value = \"John Green\"\n\n-- when value == \"\", negative ttl is used; otherwise positive ttl is used.\nmy_shdict_set(ctx, key, value)\n\n-- it is also possible to override the default ttl for a single method call:\nmy_shdict_set(ctx, key, value, my_temp_ttl)\n\nlocal res, stale = my_shdict_get(ctx, key)\nif not res then\n    if stale then\n        -- use the stale data in the cache...\n    end\nend\n```\n\nTODO\n====\n\n\nAuthor\n======\n\nYichun \"agentzh\" Zhang (章亦春) \u003cagentzh@gmail.com\u003e, CloudFlare Inc.\n\n[Back to TOC](#table-of-contents)\n\nCopyright and License\n=====================\n\nThis module is licensed under the BSD license.\n\nCopyright (C) 2016, by CloudFlare Inc.\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n[Back to TOC](#table-of-contents)\n\nSee Also\n========\n\n* [lua-resty-memcached-shdict](https://github.com/openresty/lua-resty-memcached-shdict)\n* [lua-resty-lrucache](https://github.com/openresty/lua-resty-lrucache)\n* [lua-resty-memcached](https://github.com/openresty/lua-resty-memcached)\n* [lua_shared_dict](https://github.com/openresty/lua-nginx-module#lua_shared_dict)\n\n[Back to TOC](#table-of-contents)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenresty%2Flua-resty-shdict-simple","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenresty%2Flua-resty-shdict-simple","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenresty%2Flua-resty-shdict-simple/lists"}