{"id":21062717,"url":"https://github.com/phanxgames/phanx-redis","last_synced_at":"2025-07-11T16:34:07.970Z","repository":{"id":57322818,"uuid":"109522640","full_name":"phanxgames/phanx-redis","owner":"phanxgames","description":"Redis wrapper adding promise and typescript support for Node.js","archived":false,"fork":false,"pushed_at":"2020-02-03T02:39:30.000Z","size":33,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-22T02:53:03.654Z","etag":null,"topics":["async","nodejs","promise","redis","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phanxgames.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}},"created_at":"2017-11-04T19:08:16.000Z","updated_at":"2020-02-03T02:39:32.000Z","dependencies_parsed_at":"2022-09-10T18:22:14.257Z","dependency_job_id":null,"html_url":"https://github.com/phanxgames/phanx-redis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phanxgames/phanx-redis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phanxgames%2Fphanx-redis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phanxgames%2Fphanx-redis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phanxgames%2Fphanx-redis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phanxgames%2Fphanx-redis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phanxgames","download_url":"https://codeload.github.com/phanxgames/phanx-redis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phanxgames%2Fphanx-redis/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264851643,"owners_count":23673270,"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":["async","nodejs","promise","redis","typescript"],"created_at":"2024-11-19T17:40:15.378Z","updated_at":"2025-07-11T16:34:07.676Z","avatar_url":"https://github.com/phanxgames.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Redis wrapper adding promise and typescript support.\n\n### Features\n\n* Provided Typescript source code.\n* Exposes all REDIS commands and wraps them with promises.\n* Provides two helper methods for searching and looping through values:  getSearch and delSearch.\n\n### install\n\n\u003cpre\u003e\nnpm install phanx-redis\n\u003c/pre\u003e\n\n### Requirements\n\n* ECMAScript 2016 (ES6)\n* Node.JS 6.x or later (tested on 6.11)\n\n\n### Basic Example\n\n\u003cpre\u003e\n\nlet PhanxRedis = require(\"phanx-redis\");\n\nlet config = {\n\thost: \"127.0.0.1\"\n};\n\nlet rs = new PhanxRedis(config);\n\nasync function run() {\n    await rs.set(\"key\",\"test\");\n    console.log(\"set key!\");\n\n    //get key value and return to value after async operation completes\n    let keyvalue = await rs.get(\"key\");\n    console.log(\"key=\",keyvalue);\n\n}\nrun();\n\n\u003c/pre\u003e\n\n## Helper Methods exclusive to this module:\n\n\n#### getDefault(key,defaultValue)\n\nJust like the standard .get(key) method, but instead will allow you to provide a default value if the key is not found or is null.\n\n\u003cpre\u003e\nlet value = await rs.getDefault(\"undefined key\",\"not found\");\nconsole.log(value); //outputs \"not found\"\n\u003c/pre\u003e\n\n\n#### getJson(key)\n\nWill attempt to automatically parse the JSON and return the object.\n\n\u003cpre\u003e\nawait rs.set(\"an object\",JSON.stringify({foo:\"bar\"}));\n\nlet obj = await rs.getJson(\"an object\");\nconsole.log(obj.foo); //outputs: \"bar\"\n\u003c/pre\u003e\n\n\n#### setJson(key, object)\n\nWill attempt to convert passed in object to JSON and save to key.\n\n\u003cpre\u003e\nawait rs.setJson(\"key\",{foo:\"bar\"});\n\n// .. later ..\n\nlet obj = await rs.getJson(\"key\");\nconsole.log(obj.foo); //outputs: \"bar\"\n\u003c/pre\u003e\n\n\n#### getSearch(key, callback(key,value,cbnext) )\n\nThis method allows you to loop over key/values that match your search criteria.\nInternally it uses the SCAN redis command.\n\n\u003cpre\u003e\n\t//lets add a whole bunch of keys\n\tawait rs.set(\"chara_a\",1);\n\tawait rs.set(\"chara_b\",2);\n\tawait rs.set(\"chara_c\",3);\n\tawait rs.set(\"chara_d\",4);\n\tawait rs.set(\"chara_e\",5);\n\tawait rs.set(\"chara_f\",6);\n\n\tawait rs.getSearch(\"chara_*\",function(key,value,cbNext) {\n\t\tconsole.log(\"   \",key,value);\n\t\tcbNext();\n\t});\n\n\tconsole.log(\"search complete\");\n\u003c/pre\u003e\n\nAlternatively, you can return the search result in a Dictionary (dictionaryjs) collection and use all the great dictionaryjs methods to iterate through it.\n\n\u003cpre\u003e\n    let rows = await rs.getSearch(\"chara_*\");\n    console.log(result);\n\n    for (let row of rows) {\n        console.log(row);\n    }\n\u003c/pre\u003e\n\n#### delSearch(key)\n\nThis method is similar to the getSearch method, but instead of allowing you to loop\nthrough the results, it deletes them, and then returns the delete count.\n\n\u003cpre\u003e\n\tlet delcount = await rs.delSearch(\"chara_*\");\n\tconsole.log(\"deleted \" + delcount + \" keys\");\n\u003c/pre\u003e\n\n\n### multi() Functionality\n\nMulti allows commands to be queued together, and ensures that all commands succeed or all fail.\n\n.mutli() chaining functionality is not supported by this module.\nYou may access its functionality by not chaining it. Such as:\n\n\u003cpre\u003e\n\tlet multi = rs.multi();\n\n\tmulti.dbsize();\n\tmulti.set(\"test\",\"blah\");\n\tmulti.set(\"phanx\",\"games\");\n\tmulti.dbsize();\n\n    let results = await multi.exec();\n    console.log(results);\n\u003c/pre\u003e\n\n\n### Error Handling\n\nYou can disable errors being thrown and handle errors by checking if an error existed in the previous operation.\n\n\u003cpre\u003e\n\nrs.throwErrors = false;\n\nawait rs.get(\"key\");\n\nif (rs.error) {\n    //handle error\n} else {\n    //do something with the last operation's result\n    let value = rs.result;\n}\n\n\u003c/pre\u003e\n\nOtherwise, by default throwErrors is true, and thus you will need to handle errors using try/catch.\n\n### Based on node_redis\n\nThis module wraps the \u003ca href=\"https://github.com/NodeRedis/node_redis\"\u003enode_redis\u003c/a\u003e module.\nPlease review this module for more information about what methods and commands are available to you.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphanxgames%2Fphanx-redis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphanxgames%2Fphanx-redis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphanxgames%2Fphanx-redis/lists"}