{"id":21850664,"url":"https://github.com/stephenmp/ts-ioredis-pool","last_synced_at":"2026-04-19T03:32:37.900Z","repository":{"id":57380827,"uuid":"420827279","full_name":"StephenMP/ts-ioredis-pool","owner":"StephenMP","description":"Connection pooling for ioredis in TypeScript","archived":false,"fork":false,"pushed_at":"2021-11-06T04:01:15.000Z","size":88,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T03:02:12.209Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/StephenMP.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":"2021-10-25T00:15:16.000Z","updated_at":"2024-01-06T20:43:32.000Z","dependencies_parsed_at":"2022-09-19T16:52:00.180Z","dependency_job_id":null,"html_url":"https://github.com/StephenMP/ts-ioredis-pool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenMP%2Fts-ioredis-pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenMP%2Fts-ioredis-pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenMP%2Fts-ioredis-pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephenMP%2Fts-ioredis-pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StephenMP","download_url":"https://codeload.github.com/StephenMP/ts-ioredis-pool/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244843226,"owners_count":20519779,"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-11-28T00:18:44.689Z","updated_at":"2026-04-19T03:32:37.848Z","avatar_url":"https://github.com/StephenMP.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ts-ioredis-pool\n\n[![CI](https://github.com/StephenMP/ts-ioredis-pool/actions/workflows/CI.yaml/badge.svg?branch=main\u0026event=push)](https://github.com/StephenMP/ts-ioredis-pool/actions/workflows/CI.yaml)\n\nConnection pooling for ioredis in TypeScript.\n\nSupports\n- Node 10+\n- Redis 4+\n\n## Usage\n\nBasic usage:\n\n```typescript\n// In some file (e.g. src/pool.ts)\nconst ioRedisPoolOpts = IORedisPoolOptions\n  .fromUrl(process.env.REDIS_URL as string)\n  // This accepts the RedisOptions class from ioredis as an argument\n  // https://github.com/luin/ioredis/blob/master/lib/redis/RedisOptions.ts\n  .withIORedisOptions({\n    name: 'test',\n    keyPrefix: 'ioredis_test_',\n  })\n  // This accepts the Options class from @types/generic-pool as an argument\n  // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/generic-pool/index.d.ts#L36\n  .withPoolOptions({\n    min: 2,\n    max: 20,\n  })\n\nexport const ioRedisPool = new IORedisPool(ioRedisPoolOpts)\n\n// In some other file (e.g. src/myfile.ts)\nimport { ioRedisPool } from './pool.ts'\n\n// ...some code\n\nasync function setRedis(key: string, obj: any) {\n  const client = await pool.getConnection()\n  if (client) {\n    client.set(key, obj)\n\n    // Don't forget to release your connection\n    await pool.release(client)\n  }\n}\n```\n\nYou can also connect via host and port:\n\n```typescript\n// In some file (e.g. src/pool.ts)\nconst ioRedisPoolOpts = IORedisPoolOptions\n  .fromHostAndPort(\n    process.env.REDIS_HOST as string,\n    parseInt(process.env.REDIS_PORT as string)\n  )\n  .withIORedisOptions({\n    name: 'test',\n    keyPrefix: 'ioredis_test_',\n    password: process.env.REDIS_PASS as string,\n  })\n  .withPoolOptions({\n    min: 2,\n    max: 20,\n  })\n\nexport const ioRedisPool = new IORedisPool(ioRedisPoolOpts)\n```\n\nA more anonymous way of executing redis commands. This allows you access to the ioredis client methods while also managing the acquisition and release of the connections from the pool for you so you don't have to worry about it.\n\n```typescript\n// assuming you already have an IORedisPool instance\nconst someValue = await ioRedisPool.execute(async (client) =\u003e {\n  // Here you have access to ioredis commands\n  return await client.get('some-key')\n})\n\n// You can run multiple commands\nawait ioRedisPool.execute(async (client) =\u003e {\n  // Here you have access to ioredis commands\n  const set = client.set('some-key', 'some-value')\n  const del = client.del('some-other-key')\n\n  await Promise.all([set, del])\n  return await client.get('another-key')\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenmp%2Fts-ioredis-pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephenmp%2Fts-ioredis-pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenmp%2Fts-ioredis-pool/lists"}