@upstash/redis 0.0.0-ci.babdc47f97e036e2863dfed16300cda2b97bf6ad-20240322001434 → 0.0.0-ci.bb93ac2803c2e927dc8bf1a1b3c5aa2a14034eb6-20240930061920
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +2 -0
- package/.github/workflows/release.yml +53 -0
- package/.github/workflows/tests.yaml +609 -0
- package/.gitignore +175 -0
- package/.husky/commit-msg +1 -0
- package/.husky/pre-commit +2 -0
- package/.husky/pre-push +1 -0
- package/.prettierignore +1 -0
- package/.vscode/extensions.json +3 -0
- package/.vscode/settings.json +20 -0
- package/README.md +1 -2
- package/bun.lockb +0 -0
- package/commitlint.config.js +46 -0
- package/dist/LICENSE +21 -0
- package/dist/README.md +136 -0
- package/dist/chunk-TEVCO3ZO.mjs +3797 -0
- package/dist/cloudflare.d.mts +55 -0
- package/dist/cloudflare.d.ts +55 -0
- package/dist/cloudflare.js +3907 -0
- package/dist/cloudflare.mjs +91 -0
- package/dist/fastly.d.mts +48 -0
- package/dist/fastly.d.ts +48 -0
- package/dist/fastly.js +3880 -0
- package/dist/fastly.mjs +64 -0
- package/dist/nodejs.d.mts +73 -0
- package/dist/nodejs.d.ts +73 -0
- package/dist/nodejs.js +3926 -0
- package/dist/nodejs.mjs +110 -0
- package/dist/package.json +1 -0
- package/{zmscore-5d82e632.d.ts → dist/zmscore-BhX8yEQc.d.mts} +249 -184
- package/dist/zmscore-BhX8yEQc.d.ts +3486 -0
- package/eslint.config.mjs +102 -0
- package/examples/auto-pipeline/.eslintrc.json +3 -0
- package/examples/auto-pipeline/README.md +77 -0
- package/examples/auto-pipeline/app/components/DataComponent.tsx +49 -0
- package/examples/auto-pipeline/app/data/getEvents.ts +18 -0
- package/examples/auto-pipeline/app/data/getUsers.ts +18 -0
- package/examples/auto-pipeline/app/data/redis.ts +12 -0
- package/examples/auto-pipeline/app/favicon.ico +0 -0
- package/examples/auto-pipeline/app/globals.css +0 -0
- package/examples/auto-pipeline/app/layout.tsx +22 -0
- package/examples/auto-pipeline/app/page.tsx +15 -0
- package/examples/auto-pipeline/next.config.mjs +4 -0
- package/examples/auto-pipeline/package.json +27 -0
- package/examples/auto-pipeline/postcss.config.mjs +8 -0
- package/examples/auto-pipeline/public/next.svg +1 -0
- package/examples/auto-pipeline/public/vercel.svg +1 -0
- package/examples/auto-pipeline/tailwind.config.ts +20 -0
- package/examples/auto-pipeline/tsconfig.json +26 -0
- package/examples/aws-cdk-python/README.md +36 -0
- package/examples/aws-cdk-python/cdk.json +72 -0
- package/examples/aws-cdk-python/jest.config.js +8 -0
- package/examples/aws-cdk-python/lib/api/index.py +10 -0
- package/examples/aws-cdk-python/lib/api/requirements.txt +1 -0
- package/examples/aws-cdk-python/package-lock.json +4470 -0
- package/examples/aws-cdk-python/package.json +27 -0
- package/examples/aws-cdk-python/tsconfig.json +31 -0
- package/examples/aws-cdk-typescript/README.md +36 -0
- package/examples/aws-cdk-typescript/cdk.json +72 -0
- package/examples/aws-cdk-typescript/jest.config.js +8 -0
- package/examples/aws-cdk-typescript/package-lock.json +4548 -0
- package/examples/aws-cdk-typescript/package.json +28 -0
- package/examples/aws-cdk-typescript/tsconfig.json +31 -0
- package/examples/aws-lambda/README.md +39 -0
- package/examples/aws-lambda/index.js +11 -0
- package/examples/aws-lambda/package-lock.json +27 -0
- package/examples/aws-lambda/package.json +6 -0
- package/examples/aws-sam/README.md +34 -0
- package/examples/aws-sam/__init__.py +0 -0
- package/examples/aws-sam/events/event.json +62 -0
- package/examples/aws-sam/hello_world/__init__.py +0 -0
- package/examples/aws-sam/hello_world/app.py +10 -0
- package/examples/aws-sam/hello_world/requirements.txt +2 -0
- package/examples/aws-sam/samconfig.toml +34 -0
- package/examples/aws-sam/template.yaml +52 -0
- package/examples/aws-sam/tests/__init__.py +0 -0
- package/examples/aws-sam/tests/integration/__init__.py +0 -0
- package/examples/aws-sam/tests/integration/test_api_gateway.py +45 -0
- package/examples/aws-sam/tests/requirements.txt +3 -0
- package/examples/aws-sam/tests/unit/__init__.py +0 -0
- package/examples/aws-sam/tests/unit/test_handler.py +72 -0
- package/examples/azure-functions/.funcignore +10 -0
- package/examples/azure-functions/.vscode/extensions.json +5 -0
- package/examples/azure-functions/README.md +67 -0
- package/examples/azure-functions/host.json +15 -0
- package/examples/azure-functions/package-lock.json +1019 -0
- package/examples/azure-functions/package.json +24 -0
- package/examples/azure-functions/src/functions/CounterFunction.ts +19 -0
- package/examples/azure-functions/tsconfig.json +10 -0
- package/examples/cloudflare-workers/README.md +26 -0
- package/examples/cloudflare-workers/bun.lockb +0 -0
- package/examples/cloudflare-workers/ci.test.ts +18 -0
- package/examples/cloudflare-workers/index.js +11 -0
- package/examples/cloudflare-workers/package.json +17 -0
- package/examples/cloudflare-workers/wrangler.toml +11 -0
- package/examples/cloudflare-workers-with-typescript/README.md +26 -0
- package/examples/cloudflare-workers-with-typescript/ci.test.ts +17 -0
- package/examples/cloudflare-workers-with-typescript/package.json +17 -0
- package/examples/cloudflare-workers-with-typescript/src/index.ts +16 -0
- package/examples/cloudflare-workers-with-typescript/tsconfig.json +105 -0
- package/examples/cloudflare-workers-with-typescript/wrangler.toml +9 -0
- package/examples/deno/main.test.ts +16 -0
- package/examples/deno/main.ts +9 -0
- package/examples/fastapi/README.md +23 -0
- package/examples/fastapi/main.py +12 -0
- package/examples/fastapi/requirements.txt +2 -0
- package/examples/fastly/README.md +7 -0
- package/examples/fastly/fastly.toml +12 -0
- package/examples/fastly/package.json +23 -0
- package/examples/fastly/src/index.js +19 -0
- package/examples/fastly/webpack.config.js +28 -0
- package/examples/google-cloud-functions/README.md +37 -0
- package/examples/google-cloud-functions/index.js +12 -0
- package/examples/google-cloud-functions/package.json +7 -0
- package/examples/ion/.env.example +2 -0
- package/examples/ion/.eslintrc.json +3 -0
- package/examples/ion/README.md +49 -0
- package/examples/ion/app/favicon.ico +0 -0
- package/examples/ion/app/globals.css +33 -0
- package/examples/ion/app/layout.tsx +22 -0
- package/examples/ion/app/page.tsx +12 -0
- package/examples/ion/next.config.mjs +4 -0
- package/examples/ion/package-lock.json +6709 -0
- package/examples/ion/package.json +28 -0
- package/examples/ion/postcss.config.mjs +8 -0
- package/examples/ion/public/next.svg +1 -0
- package/examples/ion/public/vercel.svg +1 -0
- package/examples/ion/sst-env.d.ts +12 -0
- package/examples/ion/sst.config.ts +19 -0
- package/examples/ion/tailwind.config.ts +20 -0
- package/examples/ion/tsconfig.json +26 -0
- package/examples/nextjs-app-router/.env.example +2 -0
- package/examples/nextjs-app-router/.eslintrc.json +3 -0
- package/examples/nextjs-app-router/README.md +26 -0
- package/examples/nextjs-app-router/app/globals.css +3 -0
- package/examples/nextjs-app-router/app/layout.tsx +22 -0
- package/examples/nextjs-app-router/app/page.tsx +12 -0
- package/examples/nextjs-app-router/next.config.mjs +4 -0
- package/examples/nextjs-app-router/package.json +27 -0
- package/examples/nextjs-app-router/postcss.config.mjs +8 -0
- package/examples/nextjs-app-router/tailwind.config.ts +20 -0
- package/examples/nextjs-app-router/tsconfig.json +26 -0
- package/examples/nextjs-pages-router/.env.example +2 -0
- package/examples/nextjs-pages-router/.eslintrc.json +3 -0
- package/examples/nextjs-pages-router/README.md +26 -0
- package/examples/nextjs-pages-router/next.config.mjs +6 -0
- package/examples/nextjs-pages-router/package.json +27 -0
- package/examples/nextjs-pages-router/pages/_app.tsx +6 -0
- package/examples/nextjs-pages-router/pages/_document.tsx +13 -0
- package/examples/nextjs-pages-router/pages/api/hello.ts +13 -0
- package/examples/nextjs-pages-router/pages/index.tsx +19 -0
- package/examples/nextjs-pages-router/postcss.config.mjs +8 -0
- package/examples/nextjs-pages-router/styles/globals.css +3 -0
- package/examples/nextjs-pages-router/tailwind.config.ts +20 -0
- package/examples/nextjs-pages-router/tsconfig.json +21 -0
- package/examples/nodejs/.env.example +2 -0
- package/examples/nodejs/README.md +24 -0
- package/examples/nodejs/index.js +10 -0
- package/examples/nodejs/package.json +10 -0
- package/examples/serverless-framework/counter/.env.example +2 -0
- package/examples/serverless-framework/counter/README.md +38 -0
- package/examples/serverless-framework/counter/handler.js +12 -0
- package/examples/serverless-framework/counter/package-lock.json +27 -0
- package/examples/serverless-framework/counter/package.json +6 -0
- package/examples/serverless-framework/counter/serverless.yml +16 -0
- package/examples/sst-v2/.vscode/launch.json +15 -0
- package/examples/sst-v2/.vscode/settings.json +5 -0
- package/examples/sst-v2/README.md +62 -0
- package/examples/sst-v2/package.json +27 -0
- package/examples/sst-v2/packages/core/package.json +14 -0
- package/examples/sst-v2/packages/core/sst-env.d.ts +1 -0
- package/examples/sst-v2/packages/core/tsconfig.json +7 -0
- package/examples/sst-v2/packages/functions/package.json +15 -0
- package/examples/sst-v2/packages/functions/sst-env.d.ts +1 -0
- package/examples/sst-v2/packages/functions/tsconfig.json +11 -0
- package/examples/sst-v2/packages/web/README.md +40 -0
- package/examples/sst-v2/packages/web/next.config.mjs +6 -0
- package/examples/sst-v2/packages/web/package.json +23 -0
- package/examples/sst-v2/packages/web/pages/_app.tsx +6 -0
- package/examples/sst-v2/packages/web/pages/_document.tsx +13 -0
- package/examples/sst-v2/packages/web/pages/api/hello.ts +16 -0
- package/examples/sst-v2/packages/web/pages/index.tsx +114 -0
- package/examples/sst-v2/packages/web/public/favicon.ico +0 -0
- package/examples/sst-v2/packages/web/public/next.svg +1 -0
- package/examples/sst-v2/packages/web/public/vercel.svg +1 -0
- package/examples/sst-v2/packages/web/sst-env.d.ts +1 -0
- package/examples/sst-v2/packages/web/styles/Home.module.css +229 -0
- package/examples/sst-v2/packages/web/styles/globals.css +107 -0
- package/examples/sst-v2/packages/web/tsconfig.json +36 -0
- package/examples/sst-v2/pnpm-workspace.yaml +2 -0
- package/examples/sst-v2/sst.config.ts +14 -0
- package/examples/sst-v2/stacks/Default.ts +13 -0
- package/examples/sst-v2/tsconfig.json +8 -0
- package/examples/terraform/README.md +38 -0
- package/examples/terraform/counter/counter.js +11 -0
- package/examples/terraform/counter/package.json +6 -0
- package/examples/terraform/main.tf +166 -0
- package/examples/terraform/outputs.tf +17 -0
- package/examples/terraform/terraform.tf +18 -0
- package/examples/terraform/variables.tf +6 -0
- package/examples/vercel-functions-app-router/.env.example +2 -0
- package/examples/vercel-functions-app-router/.eslintrc.json +3 -0
- package/examples/vercel-functions-app-router/README.md +26 -0
- package/examples/vercel-functions-app-router/app/api/hello/route.ts +11 -0
- package/examples/vercel-functions-app-router/app/globals.css +3 -0
- package/examples/vercel-functions-app-router/app/layout.tsx +22 -0
- package/examples/vercel-functions-app-router/ci.test.ts +14 -0
- package/examples/vercel-functions-app-router/next.config.mjs +4 -0
- package/examples/vercel-functions-app-router/package.json +27 -0
- package/examples/vercel-functions-app-router/postcss.config.mjs +8 -0
- package/examples/vercel-functions-app-router/tailwind.config.ts +20 -0
- package/examples/vercel-functions-app-router/tsconfig.json +26 -0
- package/examples/vercel-functions-pages-router/.env.example +2 -0
- package/examples/vercel-functions-pages-router/.eslintrc.json +3 -0
- package/examples/vercel-functions-pages-router/README.md +26 -0
- package/examples/vercel-functions-pages-router/ci.test.ts +14 -0
- package/examples/vercel-functions-pages-router/next.config.mjs +6 -0
- package/examples/vercel-functions-pages-router/package.json +27 -0
- package/examples/vercel-functions-pages-router/pages/_app.tsx +6 -0
- package/examples/vercel-functions-pages-router/pages/_document.tsx +13 -0
- package/examples/vercel-functions-pages-router/pages/api/hello.ts +12 -0
- package/examples/vercel-functions-pages-router/postcss.config.mjs +8 -0
- package/examples/vercel-functions-pages-router/styles/globals.css +3 -0
- package/examples/vercel-functions-pages-router/tailwind.config.ts +20 -0
- package/examples/vercel-functions-pages-router/tsconfig.json +21 -0
- package/examples/vercel-python-runtime-django/.env.example +2 -0
- package/examples/vercel-python-runtime-django/README.md +34 -0
- package/examples/vercel-python-runtime-django/api/__init__.py +0 -0
- package/examples/vercel-python-runtime-django/api/asgi.py +16 -0
- package/examples/vercel-python-runtime-django/api/settings.py +121 -0
- package/examples/vercel-python-runtime-django/api/urls.py +22 -0
- package/examples/vercel-python-runtime-django/api/wsgi.py +16 -0
- package/examples/vercel-python-runtime-django/example/__init__.py +0 -0
- package/examples/vercel-python-runtime-django/example/admin.py +3 -0
- package/examples/vercel-python-runtime-django/example/apps.py +6 -0
- package/examples/vercel-python-runtime-django/example/urls.py +9 -0
- package/examples/vercel-python-runtime-django/example/views.py +18 -0
- package/examples/vercel-python-runtime-django/manage.py +22 -0
- package/examples/vercel-python-runtime-django/package.json +5 -0
- package/examples/vercel-python-runtime-django/requirements.txt +2 -0
- package/examples/vercel-python-runtime-django/vercel.json +8 -0
- package/examples/with-sentry/index.ts +36 -0
- package/examples/with-sentry/package.json +17 -0
- package/package.json +1 -1
- package/pkg/auto-pipeline.test.ts +321 -0
- package/pkg/auto-pipeline.ts +107 -0
- package/pkg/commands/append.test.ts +28 -0
- package/pkg/commands/append.ts +11 -0
- package/pkg/commands/bitcount.test.ts +37 -0
- package/pkg/commands/bitcount.ts +29 -0
- package/pkg/commands/bitfield.test.ts +51 -0
- package/pkg/commands/bitfield.ts +50 -0
- package/pkg/commands/bitop.test.ts +45 -0
- package/pkg/commands/bitop.ts +22 -0
- package/pkg/commands/bitpos.test.ts +47 -0
- package/pkg/commands/bitpos.ts +14 -0
- package/pkg/commands/command.test.ts +22 -0
- package/pkg/commands/command.ts +98 -0
- package/pkg/commands/copy.test.ts +65 -0
- package/pkg/commands/copy.ts +22 -0
- package/pkg/commands/dbsize.test.ts +18 -0
- package/pkg/commands/dbsize.ts +11 -0
- package/pkg/commands/decr.test.ts +23 -0
- package/pkg/commands/decr.ts +11 -0
- package/pkg/commands/decrby.test.ts +24 -0
- package/pkg/commands/decrby.ts +11 -0
- package/pkg/commands/del.test.ts +38 -0
- package/pkg/commands/del.ts +11 -0
- package/pkg/commands/echo.test.ts +11 -0
- package/pkg/commands/echo.ts +11 -0
- package/pkg/commands/eval.test.ts +30 -0
- package/pkg/commands/eval.ts +14 -0
- package/pkg/commands/evalsha.test.ts +19 -0
- package/pkg/commands/evalsha.ts +14 -0
- package/pkg/commands/exists.test.ts +38 -0
- package/pkg/commands/exists.ts +11 -0
- package/pkg/commands/expire.test.ts +119 -0
- package/pkg/commands/expire.ts +12 -0
- package/pkg/commands/expireat.test.ts +25 -0
- package/pkg/commands/expireat.ts +11 -0
- package/pkg/commands/flushall.test.ts +18 -0
- package/pkg/commands/flushall.ts +14 -0
- package/pkg/commands/flushdb.test.ts +17 -0
- package/pkg/commands/flushdb.ts +14 -0
- package/pkg/commands/geo_add.test.ts +202 -0
- package/pkg/commands/geo_add.ts +54 -0
- package/pkg/commands/geo_dist.test.ts +79 -0
- package/pkg/commands/geo_dist.ts +19 -0
- package/pkg/commands/geo_hash.test.ts +49 -0
- package/pkg/commands/geo_hash.ts +23 -0
- package/pkg/commands/geo_pos.test.ts +60 -0
- package/pkg/commands/geo_pos.ts +39 -0
- package/pkg/commands/geo_search.test.ts +197 -0
- package/pkg/commands/geo_search.ts +139 -0
- package/pkg/commands/geo_search_store.test.ts +153 -0
- package/pkg/commands/geo_search_store.ts +69 -0
- package/pkg/commands/get.test.ts +35 -0
- package/pkg/commands/get.ts +11 -0
- package/pkg/commands/getbit.test.ts +17 -0
- package/pkg/commands/getbit.ts +11 -0
- package/pkg/commands/getdel.test.ts +39 -0
- package/pkg/commands/getdel.ts +11 -0
- package/pkg/commands/getrange.test.ts +25 -0
- package/pkg/commands/getrange.ts +14 -0
- package/pkg/commands/getset.test.ts +33 -0
- package/pkg/commands/getset.ts +14 -0
- package/pkg/commands/hdel.test.ts +45 -0
- package/pkg/commands/hdel.ts +11 -0
- package/pkg/commands/hexists.test.ts +36 -0
- package/pkg/commands/hexists.ts +11 -0
- package/pkg/commands/hget.test.ts +52 -0
- package/pkg/commands/hget.ts +14 -0
- package/pkg/commands/hgetall.test.ts +45 -0
- package/pkg/commands/hgetall.ts +37 -0
- package/pkg/commands/hincrby.test.ts +28 -0
- package/pkg/commands/hincrby.ts +14 -0
- package/pkg/commands/hincrbyfloat.test.ts +28 -0
- package/pkg/commands/hincrbyfloat.ts +14 -0
- package/pkg/commands/hkeys.test.ts +23 -0
- package/pkg/commands/hkeys.ts +11 -0
- package/pkg/commands/hlen.test.ts +25 -0
- package/pkg/commands/hlen.ts +11 -0
- package/pkg/commands/hmget.test.ts +44 -0
- package/pkg/commands/hmget.ts +46 -0
- package/pkg/commands/hmset.test.ts +23 -0
- package/pkg/commands/hmset.ts +14 -0
- package/pkg/commands/hrandfield.test.ts +59 -0
- package/pkg/commands/hrandfield.ts +50 -0
- package/pkg/commands/hscan.test.ts +44 -0
- package/pkg/commands/hscan.ts +30 -0
- package/pkg/commands/hset.test.ts +21 -0
- package/pkg/commands/hset.ts +14 -0
- package/pkg/commands/hsetnx.test.ts +37 -0
- package/pkg/commands/hsetnx.ts +14 -0
- package/pkg/commands/hstrlen.test.ts +24 -0
- package/pkg/commands/hstrlen.ts +11 -0
- package/pkg/commands/hvals.test.ts +24 -0
- package/pkg/commands/hvals.ts +11 -0
- package/pkg/commands/incr.test.ts +24 -0
- package/pkg/commands/incr.ts +11 -0
- package/pkg/commands/incrby.test.ts +24 -0
- package/pkg/commands/incrby.ts +11 -0
- package/pkg/commands/incrbyfloat.test.ts +25 -0
- package/pkg/commands/incrbyfloat.ts +11 -0
- package/pkg/commands/json_arrappend.test.ts +40 -0
- package/pkg/commands/json_arrappend.ts +17 -0
- package/pkg/commands/json_arrindex.test.ts +54 -0
- package/pkg/commands/json_arrindex.ts +14 -0
- package/pkg/commands/json_arrinsert.test.ts +49 -0
- package/pkg/commands/json_arrinsert.ts +17 -0
- package/pkg/commands/json_arrlen.test.ts +31 -0
- package/pkg/commands/json_arrlen.ts +14 -0
- package/pkg/commands/json_arrpop.test.ts +30 -0
- package/pkg/commands/json_arrpop.ts +14 -0
- package/pkg/commands/json_arrtrim.test.ts +31 -0
- package/pkg/commands/json_arrtrim.ts +18 -0
- package/pkg/commands/json_clear.test.ts +35 -0
- package/pkg/commands/json_clear.ts +11 -0
- package/pkg/commands/json_del.test.ts +29 -0
- package/pkg/commands/json_del.ts +11 -0
- package/pkg/commands/json_forget.test.ts +29 -0
- package/pkg/commands/json_forget.ts +11 -0
- package/pkg/commands/json_get.test.ts +28 -0
- package/pkg/commands/json_get.ts +44 -0
- package/pkg/commands/json_mget.test.ts +43 -0
- package/pkg/commands/json_mget.ts +11 -0
- package/pkg/commands/json_mset.test.ts +50 -0
- package/pkg/commands/json_mset.ts +26 -0
- package/pkg/commands/json_numincrby.test.ts +28 -0
- package/pkg/commands/json_numincrby.ts +14 -0
- package/pkg/commands/json_nummultby.test.ts +28 -0
- package/pkg/commands/json_nummultby.ts +14 -0
- package/pkg/commands/json_objkeys.test.ts +32 -0
- package/pkg/commands/json_objkeys.ts +14 -0
- package/pkg/commands/json_objlen.test.ts +26 -0
- package/pkg/commands/json_objlen.ts +14 -0
- package/pkg/commands/json_resp.test.ts +31 -0
- package/pkg/commands/json_resp.ts +11 -0
- package/pkg/commands/json_set.test.ts +48 -0
- package/pkg/commands/json_set.ts +34 -0
- package/pkg/commands/json_strappend.test.ts +34 -0
- package/pkg/commands/json_strappend.ts +14 -0
- package/pkg/commands/json_strlen.test.ts +27 -0
- package/pkg/commands/json_strlen.ts +14 -0
- package/pkg/commands/json_toggle.test.ts +26 -0
- package/pkg/commands/json_toggle.ts +11 -0
- package/pkg/commands/json_type.test.ts +29 -0
- package/pkg/commands/json_type.ts +11 -0
- package/pkg/commands/keys.test.ts +18 -0
- package/pkg/commands/keys.ts +11 -0
- package/pkg/commands/lindex.test.ts +33 -0
- package/pkg/commands/lindex.ts +11 -0
- package/pkg/commands/linsert.test.ts +24 -0
- package/pkg/commands/linsert.ts +10 -0
- package/pkg/commands/llen.test.ts +27 -0
- package/pkg/commands/llen.ts +11 -0
- package/pkg/commands/lmove.test.ts +48 -0
- package/pkg/commands/lmove.ts +19 -0
- package/pkg/commands/lmpop.test.ts +86 -0
- package/pkg/commands/lmpop.ts +19 -0
- package/pkg/commands/lpop.test.ts +40 -0
- package/pkg/commands/lpop.ts +14 -0
- package/pkg/commands/lpos.test.ts +56 -0
- package/pkg/commands/lpos.ts +25 -0
- package/pkg/commands/lpush.test.ts +18 -0
- package/pkg/commands/lpush.ts +11 -0
- package/pkg/commands/lpushx.test.ts +30 -0
- package/pkg/commands/lpushx.ts +11 -0
- package/pkg/commands/lrange.test.ts +21 -0
- package/pkg/commands/lrange.ts +11 -0
- package/pkg/commands/lrem.test.ts +19 -0
- package/pkg/commands/lrem.ts +10 -0
- package/pkg/commands/lset.test.ts +43 -0
- package/pkg/commands/lset.ts +8 -0
- package/pkg/commands/ltrim.test.ts +30 -0
- package/pkg/commands/ltrim.ts +8 -0
- package/pkg/commands/mget.test.ts +44 -0
- package/pkg/commands/mget.ts +11 -0
- package/pkg/commands/mod.ts +168 -0
- package/pkg/commands/mset.test.ts +24 -0
- package/pkg/commands/mset.ts +11 -0
- package/pkg/commands/msetnx.test.ts +46 -0
- package/pkg/commands/msetnx.ts +11 -0
- package/pkg/commands/persist.test.ts +22 -0
- package/pkg/commands/persist.ts +11 -0
- package/pkg/commands/pexpire.test.ts +24 -0
- package/pkg/commands/pexpire.ts +11 -0
- package/pkg/commands/pexpireat.test.ts +31 -0
- package/pkg/commands/pexpireat.ts +11 -0
- package/pkg/commands/pfadd.test.ts +80 -0
- package/pkg/commands/pfadd.ts +11 -0
- package/pkg/commands/pfcount.test.ts +55 -0
- package/pkg/commands/pfcount.ts +11 -0
- package/pkg/commands/pfmerge.test.ts +67 -0
- package/pkg/commands/pfmerge.ts +11 -0
- package/pkg/commands/ping.test.ts +19 -0
- package/pkg/commands/ping.ts +14 -0
- package/pkg/commands/psetex.test.ts +23 -0
- package/pkg/commands/psetex.ts +14 -0
- package/pkg/commands/pttl.test.ts +18 -0
- package/pkg/commands/pttl.ts +11 -0
- package/pkg/commands/publish.test.ts +12 -0
- package/pkg/commands/publish.ts +11 -0
- package/pkg/commands/randomkey.test.ts +16 -0
- package/pkg/commands/randomkey.ts +11 -0
- package/pkg/commands/rename.test.ts +19 -0
- package/pkg/commands/rename.ts +11 -0
- package/pkg/commands/renamenx.test.ts +33 -0
- package/pkg/commands/renamenx.ts +11 -0
- package/pkg/commands/rpop.test.ts +40 -0
- package/pkg/commands/rpop.ts +17 -0
- package/pkg/commands/rpush.test.ts +17 -0
- package/pkg/commands/rpush.ts +11 -0
- package/pkg/commands/rpushx.test.ts +30 -0
- package/pkg/commands/rpushx.ts +11 -0
- package/pkg/commands/sadd.test.ts +22 -0
- package/pkg/commands/sadd.ts +14 -0
- package/pkg/commands/scan.test.ts +91 -0
- package/pkg/commands/scan.ts +33 -0
- package/pkg/commands/scard.test.ts +16 -0
- package/pkg/commands/scard.ts +10 -0
- package/pkg/commands/script_exists.test.ts +34 -0
- package/pkg/commands/script_exists.ts +14 -0
- package/pkg/commands/script_flush.ts +21 -0
- package/pkg/commands/script_load.test.ts +11 -0
- package/pkg/commands/script_load.ts +11 -0
- package/pkg/commands/sdiff.test.ts +20 -0
- package/pkg/commands/sdiff.ts +10 -0
- package/pkg/commands/sdiffstore.test.ts +22 -0
- package/pkg/commands/sdiffstore.ts +13 -0
- package/pkg/commands/set.test.ts +168 -0
- package/pkg/commands/set.ts +51 -0
- package/pkg/commands/setbit.test.ts +17 -0
- package/pkg/commands/setbit.ts +14 -0
- package/pkg/commands/setex.test.ts +22 -0
- package/pkg/commands/setex.ts +11 -0
- package/pkg/commands/setnx.test.ts +27 -0
- package/pkg/commands/setnx.ts +11 -0
- package/pkg/commands/setrange.test.ts +25 -0
- package/pkg/commands/setrange.ts +14 -0
- package/pkg/commands/sinter.test.ts +37 -0
- package/pkg/commands/sinter.ts +10 -0
- package/pkg/commands/sinterstore.test.ts +22 -0
- package/pkg/commands/sinterstore.ts +13 -0
- package/pkg/commands/sismember.test.ts +31 -0
- package/pkg/commands/sismember.ts +10 -0
- package/pkg/commands/smembers.test.ts +22 -0
- package/pkg/commands/smembers.ts +11 -0
- package/pkg/commands/smismember.test.ts +22 -0
- package/pkg/commands/smismember.ts +16 -0
- package/pkg/commands/smove.test.ts +18 -0
- package/pkg/commands/smove.ts +13 -0
- package/pkg/commands/spop.test.ts +36 -0
- package/pkg/commands/spop.ts +17 -0
- package/pkg/commands/srandmember.test.ts +31 -0
- package/pkg/commands/srandmember.ts +17 -0
- package/pkg/commands/srem.test.ts +19 -0
- package/pkg/commands/srem.ts +10 -0
- package/pkg/commands/sscan.test.ts +48 -0
- package/pkg/commands/sscan.ts +30 -0
- package/pkg/commands/strlen.test.ts +17 -0
- package/pkg/commands/strlen.ts +11 -0
- package/pkg/commands/sunion.test.ts +22 -0
- package/pkg/commands/sunion.ts +11 -0
- package/pkg/commands/sunionstore.test.ts +30 -0
- package/pkg/commands/sunionstore.ts +14 -0
- package/pkg/commands/time.test.ts +12 -0
- package/pkg/commands/time.ts +10 -0
- package/pkg/commands/touch.test.ts +21 -0
- package/pkg/commands/touch.ts +11 -0
- package/pkg/commands/ttl.test.ts +17 -0
- package/pkg/commands/ttl.ts +11 -0
- package/pkg/commands/type.test.ts +72 -0
- package/pkg/commands/type.ts +12 -0
- package/pkg/commands/types.ts +150 -0
- package/pkg/commands/unlink.test.ts +22 -0
- package/pkg/commands/unlink.ts +11 -0
- package/pkg/commands/xack.test.ts +53 -0
- package/pkg/commands/xack.ts +15 -0
- package/pkg/commands/xadd.test.ts +128 -0
- package/pkg/commands/xadd.ts +64 -0
- package/pkg/commands/xautoclaim.test.ts +105 -0
- package/pkg/commands/xautoclaim.ts +30 -0
- package/pkg/commands/xclaim.test.ts +70 -0
- package/pkg/commands/xclaim.ts +55 -0
- package/pkg/commands/xdel.test.ts +50 -0
- package/pkg/commands/xdel.ts +15 -0
- package/pkg/commands/xgroup.test.ts +202 -0
- package/pkg/commands/xgroup.ts +100 -0
- package/pkg/commands/xinfo.test.ts +82 -0
- package/pkg/commands/xinfo.ts +27 -0
- package/pkg/commands/xlen.test.ts +29 -0
- package/pkg/commands/xlen.ts +11 -0
- package/pkg/commands/xpending.test.ts +94 -0
- package/pkg/commands/xpending.ts +43 -0
- package/pkg/commands/xrange.test.ts +69 -0
- package/pkg/commands/xrange.ts +48 -0
- package/pkg/commands/xread.test.ts +117 -0
- package/pkg/commands/xread.ts +51 -0
- package/pkg/commands/xreadgroup.test.ts +166 -0
- package/pkg/commands/xreadgroup.ts +66 -0
- package/pkg/commands/xrevrange.test.ts +48 -0
- package/pkg/commands/xrevrange.ts +47 -0
- package/pkg/commands/xtrim.test.ts +65 -0
- package/pkg/commands/xtrim.ts +24 -0
- package/pkg/commands/zadd.test.ts +242 -0
- package/pkg/commands/zadd.ts +53 -0
- package/pkg/commands/zcard.test.ts +16 -0
- package/pkg/commands/zcard.ts +11 -0
- package/pkg/commands/zcount.test.ts +16 -0
- package/pkg/commands/zcount.ts +13 -0
- package/pkg/commands/zdiffstore.test.ts +42 -0
- package/pkg/commands/zdiffstore.ts +14 -0
- package/pkg/commands/zincrby.test.ts +19 -0
- package/pkg/commands/zincrby.ts +13 -0
- package/pkg/commands/zinterstore.test.ts +297 -0
- package/pkg/commands/zinterstore.ts +51 -0
- package/pkg/commands/zlexcount.test.ts +23 -0
- package/pkg/commands/zlexcount.ts +10 -0
- package/pkg/commands/zmscore.test.ts +39 -0
- package/pkg/commands/zmscore.ts +15 -0
- package/pkg/commands/zpopmax.test.ts +46 -0
- package/pkg/commands/zpopmax.ts +17 -0
- package/pkg/commands/zpopmin.test.ts +50 -0
- package/pkg/commands/zpopmin.ts +17 -0
- package/pkg/commands/zrange.test.ts +188 -0
- package/pkg/commands/zrange.ts +68 -0
- package/pkg/commands/zrank.test.ts +23 -0
- package/pkg/commands/zrank.ts +14 -0
- package/pkg/commands/zrem.test.ts +21 -0
- package/pkg/commands/zrem.ts +10 -0
- package/pkg/commands/zremrangebylex.test.ts +24 -0
- package/pkg/commands/zremrangebylex.ts +10 -0
- package/pkg/commands/zremrangebyrank.test.ts +27 -0
- package/pkg/commands/zremrangebyrank.ts +13 -0
- package/pkg/commands/zremrangebyscore.test.ts +24 -0
- package/pkg/commands/zremrangebyscore.ts +10 -0
- package/pkg/commands/zrevrank.test.ts +23 -0
- package/pkg/commands/zrevrank.ts +14 -0
- package/pkg/commands/zscan.test.ts +48 -0
- package/pkg/commands/zscan.ts +30 -0
- package/pkg/commands/zscore.test.ts +18 -0
- package/pkg/commands/zscore.ts +14 -0
- package/pkg/commands/zunion.test.ts +251 -0
- package/pkg/commands/zunion.ts +54 -0
- package/pkg/commands/zunionstore.test.ts +274 -0
- package/pkg/commands/zunionstore.ts +51 -0
- package/pkg/error.ts +18 -0
- package/pkg/http.ts +349 -0
- package/pkg/index.ts +1 -0
- package/pkg/pipeline.test.ts +254 -0
- package/pkg/pipeline.ts +1401 -0
- package/pkg/read-your-writes.test.ts +115 -0
- package/pkg/redis.test.ts +250 -0
- package/pkg/redis.ts +1367 -0
- package/pkg/script.test.ts +58 -0
- package/pkg/script.ts +67 -0
- package/pkg/test-utils.test.ts +17 -0
- package/pkg/test-utils.ts +72 -0
- package/pkg/types.ts +35 -0
- package/pkg/util.ts +42 -0
- package/platforms/cloudflare.ts +144 -0
- package/platforms/fastly.ts +100 -0
- package/platforms/nodejs.ts +196 -0
- package/prettier.config.mjs +13 -0
- package/tsconfig.json +21 -0
- package/tsup.config.ts +8 -0
- package/version.ts +1 -0
- package/chunk-JD7AT2OK.js +0 -1
- package/chunk-XCPX3L6C.mjs +0 -1
- package/cloudflare.d.mts +0 -50
- package/cloudflare.d.ts +0 -50
- package/cloudflare.js +0 -1
- package/cloudflare.mjs +0 -1
- package/fastly.d.mts +0 -43
- package/fastly.d.ts +0 -43
- package/fastly.js +0 -1
- package/fastly.mjs +0 -1
- package/nodejs.d.mts +0 -85
- package/nodejs.d.ts +0 -85
- package/nodejs.js +0 -1
- package/nodejs.mjs +0 -1
package/pkg/pipeline.ts
ADDED
|
@@ -0,0 +1,1401 @@
|
|
|
1
|
+
import type { Command, CommandOptions } from "./commands/command";
|
|
2
|
+
import { HRandFieldCommand } from "./commands/hrandfield";
|
|
3
|
+
import type {
|
|
4
|
+
ScoreMember,
|
|
5
|
+
SetCommandOptions,
|
|
6
|
+
ZAddCommandOptions,
|
|
7
|
+
ZRangeCommandOptions,
|
|
8
|
+
} from "./commands/mod";
|
|
9
|
+
import {
|
|
10
|
+
AppendCommand,
|
|
11
|
+
BitCountCommand,
|
|
12
|
+
BitFieldCommand,
|
|
13
|
+
BitOpCommand,
|
|
14
|
+
BitPosCommand,
|
|
15
|
+
CopyCommand,
|
|
16
|
+
DBSizeCommand,
|
|
17
|
+
DecrByCommand,
|
|
18
|
+
DecrCommand,
|
|
19
|
+
DelCommand,
|
|
20
|
+
EchoCommand,
|
|
21
|
+
EvalCommand,
|
|
22
|
+
EvalshaCommand,
|
|
23
|
+
ExistsCommand,
|
|
24
|
+
ExpireAtCommand,
|
|
25
|
+
ExpireCommand,
|
|
26
|
+
FlushAllCommand,
|
|
27
|
+
FlushDBCommand,
|
|
28
|
+
GeoAddCommand,
|
|
29
|
+
GeoDistCommand,
|
|
30
|
+
GeoHashCommand,
|
|
31
|
+
GeoPosCommand,
|
|
32
|
+
GeoSearchCommand,
|
|
33
|
+
GeoSearchStoreCommand,
|
|
34
|
+
GetBitCommand,
|
|
35
|
+
GetCommand,
|
|
36
|
+
GetDelCommand,
|
|
37
|
+
GetRangeCommand,
|
|
38
|
+
GetSetCommand,
|
|
39
|
+
HDelCommand,
|
|
40
|
+
HExistsCommand,
|
|
41
|
+
HGetAllCommand,
|
|
42
|
+
HGetCommand,
|
|
43
|
+
HIncrByCommand,
|
|
44
|
+
HIncrByFloatCommand,
|
|
45
|
+
HKeysCommand,
|
|
46
|
+
HLenCommand,
|
|
47
|
+
HMGetCommand,
|
|
48
|
+
HMSetCommand,
|
|
49
|
+
HScanCommand,
|
|
50
|
+
HSetCommand,
|
|
51
|
+
HSetNXCommand,
|
|
52
|
+
HStrLenCommand,
|
|
53
|
+
HValsCommand,
|
|
54
|
+
IncrByCommand,
|
|
55
|
+
IncrByFloatCommand,
|
|
56
|
+
IncrCommand,
|
|
57
|
+
JsonArrAppendCommand,
|
|
58
|
+
JsonArrIndexCommand,
|
|
59
|
+
JsonArrInsertCommand,
|
|
60
|
+
JsonArrLenCommand,
|
|
61
|
+
JsonArrPopCommand,
|
|
62
|
+
JsonArrTrimCommand,
|
|
63
|
+
JsonClearCommand,
|
|
64
|
+
JsonDelCommand,
|
|
65
|
+
JsonForgetCommand,
|
|
66
|
+
JsonGetCommand,
|
|
67
|
+
JsonMGetCommand,
|
|
68
|
+
JsonMSetCommand,
|
|
69
|
+
JsonNumIncrByCommand,
|
|
70
|
+
JsonNumMultByCommand,
|
|
71
|
+
JsonObjKeysCommand,
|
|
72
|
+
JsonObjLenCommand,
|
|
73
|
+
JsonRespCommand,
|
|
74
|
+
JsonSetCommand,
|
|
75
|
+
JsonStrAppendCommand,
|
|
76
|
+
JsonStrLenCommand,
|
|
77
|
+
JsonToggleCommand,
|
|
78
|
+
JsonTypeCommand,
|
|
79
|
+
KeysCommand,
|
|
80
|
+
LIndexCommand,
|
|
81
|
+
LInsertCommand,
|
|
82
|
+
LLenCommand,
|
|
83
|
+
LMoveCommand,
|
|
84
|
+
LPopCommand,
|
|
85
|
+
LPosCommand,
|
|
86
|
+
LPushCommand,
|
|
87
|
+
LPushXCommand,
|
|
88
|
+
LRangeCommand,
|
|
89
|
+
LRemCommand,
|
|
90
|
+
LSetCommand,
|
|
91
|
+
LTrimCommand,
|
|
92
|
+
LmPopCommand,
|
|
93
|
+
MGetCommand,
|
|
94
|
+
MSetCommand,
|
|
95
|
+
MSetNXCommand,
|
|
96
|
+
PExpireAtCommand,
|
|
97
|
+
PExpireCommand,
|
|
98
|
+
PSetEXCommand,
|
|
99
|
+
PTtlCommand,
|
|
100
|
+
PersistCommand,
|
|
101
|
+
PfAddCommand,
|
|
102
|
+
PfCountCommand,
|
|
103
|
+
PfMergeCommand,
|
|
104
|
+
PingCommand,
|
|
105
|
+
PublishCommand,
|
|
106
|
+
RPopCommand,
|
|
107
|
+
RPushCommand,
|
|
108
|
+
RPushXCommand,
|
|
109
|
+
RandomKeyCommand,
|
|
110
|
+
RenameCommand,
|
|
111
|
+
RenameNXCommand,
|
|
112
|
+
SAddCommand,
|
|
113
|
+
SCardCommand,
|
|
114
|
+
SDiffCommand,
|
|
115
|
+
SDiffStoreCommand,
|
|
116
|
+
SInterCommand,
|
|
117
|
+
SInterStoreCommand,
|
|
118
|
+
SIsMemberCommand,
|
|
119
|
+
SMIsMemberCommand,
|
|
120
|
+
SMembersCommand,
|
|
121
|
+
SMoveCommand,
|
|
122
|
+
SPopCommand,
|
|
123
|
+
SRandMemberCommand,
|
|
124
|
+
SRemCommand,
|
|
125
|
+
SScanCommand,
|
|
126
|
+
SUnionCommand,
|
|
127
|
+
SUnionStoreCommand,
|
|
128
|
+
ScanCommand,
|
|
129
|
+
ScriptExistsCommand,
|
|
130
|
+
ScriptFlushCommand,
|
|
131
|
+
ScriptLoadCommand,
|
|
132
|
+
SetBitCommand,
|
|
133
|
+
SetCommand,
|
|
134
|
+
SetExCommand,
|
|
135
|
+
SetNxCommand,
|
|
136
|
+
SetRangeCommand,
|
|
137
|
+
StrLenCommand,
|
|
138
|
+
TimeCommand,
|
|
139
|
+
TouchCommand,
|
|
140
|
+
TtlCommand,
|
|
141
|
+
TypeCommand,
|
|
142
|
+
UnlinkCommand,
|
|
143
|
+
XAckCommand,
|
|
144
|
+
XAddCommand,
|
|
145
|
+
XAutoClaim,
|
|
146
|
+
XClaimCommand,
|
|
147
|
+
XDelCommand,
|
|
148
|
+
XGroupCommand,
|
|
149
|
+
XInfoCommand,
|
|
150
|
+
XLenCommand,
|
|
151
|
+
XPendingCommand,
|
|
152
|
+
XRangeCommand,
|
|
153
|
+
XReadCommand,
|
|
154
|
+
XReadGroupCommand,
|
|
155
|
+
XRevRangeCommand,
|
|
156
|
+
XTrimCommand,
|
|
157
|
+
ZAddCommand,
|
|
158
|
+
ZCardCommand,
|
|
159
|
+
ZCountCommand,
|
|
160
|
+
ZIncrByCommand,
|
|
161
|
+
ZInterStoreCommand,
|
|
162
|
+
ZLexCountCommand,
|
|
163
|
+
ZPopMaxCommand,
|
|
164
|
+
ZPopMinCommand,
|
|
165
|
+
ZRangeCommand,
|
|
166
|
+
ZRankCommand,
|
|
167
|
+
ZRemCommand,
|
|
168
|
+
ZRemRangeByLexCommand,
|
|
169
|
+
ZRemRangeByRankCommand,
|
|
170
|
+
ZRemRangeByScoreCommand,
|
|
171
|
+
ZRevRankCommand,
|
|
172
|
+
ZScanCommand,
|
|
173
|
+
ZScoreCommand,
|
|
174
|
+
ZUnionCommand,
|
|
175
|
+
ZUnionStoreCommand,
|
|
176
|
+
} from "./commands/mod";
|
|
177
|
+
import { ZDiffStoreCommand } from "./commands/zdiffstore";
|
|
178
|
+
import { ZMScoreCommand } from "./commands/zmscore";
|
|
179
|
+
import { UpstashError } from "./error";
|
|
180
|
+
import type { Requester, UpstashResponse } from "./http";
|
|
181
|
+
import type { CommandArgs } from "./types";
|
|
182
|
+
|
|
183
|
+
// Given a tuple of commands, returns a tuple of the response data of each command
|
|
184
|
+
type InferResponseData<T extends unknown[]> = {
|
|
185
|
+
[K in keyof T]: T[K] extends Command<any, infer TData> ? TData : unknown;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Upstash REST API supports command pipelining to send multiple commands in
|
|
190
|
+
* batch, instead of sending each command one by one and waiting for a response.
|
|
191
|
+
* When using pipelines, several commands are sent using a single HTTP request,
|
|
192
|
+
* and a single JSON array response is returned. Each item in the response array
|
|
193
|
+
* corresponds to the command in the same order within the pipeline.
|
|
194
|
+
*
|
|
195
|
+
* **NOTE:**
|
|
196
|
+
*
|
|
197
|
+
* Execution of the pipeline is not atomic. Even though each command in
|
|
198
|
+
* the pipeline will be executed in order, commands sent by other clients can
|
|
199
|
+
* interleave with the pipeline.
|
|
200
|
+
*
|
|
201
|
+
* **Examples:**
|
|
202
|
+
*
|
|
203
|
+
* ```ts
|
|
204
|
+
* const p = redis.pipeline() // or redis.multi()
|
|
205
|
+
* p.set("key","value")
|
|
206
|
+
* p.get("key")
|
|
207
|
+
* const res = await p.exec()
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* You can also chain commands together
|
|
211
|
+
* ```ts
|
|
212
|
+
* const p = redis.pipeline()
|
|
213
|
+
* const res = await p.set("key","value").get("key").exec()
|
|
214
|
+
* ```
|
|
215
|
+
*
|
|
216
|
+
* Return types are inferred if all commands are chained, but you can still
|
|
217
|
+
* override the response type manually:
|
|
218
|
+
* ```ts
|
|
219
|
+
* redis.pipeline()
|
|
220
|
+
* .set("key", { greeting: "hello"})
|
|
221
|
+
* .get("key")
|
|
222
|
+
* .exec<["OK", { greeting: string } ]>()
|
|
223
|
+
*
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
export class Pipeline<TCommands extends Command<any, any>[] = []> {
|
|
227
|
+
private client: Requester;
|
|
228
|
+
private commands: TCommands;
|
|
229
|
+
private commandOptions?: CommandOptions<any, any>;
|
|
230
|
+
private multiExec: boolean;
|
|
231
|
+
|
|
232
|
+
constructor(opts: {
|
|
233
|
+
client: Requester;
|
|
234
|
+
commandOptions?: CommandOptions<any, any>;
|
|
235
|
+
multiExec?: boolean;
|
|
236
|
+
}) {
|
|
237
|
+
this.client = opts.client;
|
|
238
|
+
|
|
239
|
+
this.commands = [] as unknown as TCommands; // the TCommands generic in the class definition is only used for carrying through chained command types and should never be explicitly set when instantiating the class
|
|
240
|
+
this.commandOptions = opts.commandOptions;
|
|
241
|
+
this.multiExec = opts.multiExec ?? false;
|
|
242
|
+
|
|
243
|
+
if (this.commandOptions?.latencyLogging) {
|
|
244
|
+
const originalExec = this.exec.bind(this);
|
|
245
|
+
this.exec = async <
|
|
246
|
+
TCommandResults extends unknown[] = [] extends TCommands
|
|
247
|
+
? unknown[]
|
|
248
|
+
: InferResponseData<TCommands>,
|
|
249
|
+
>(): Promise<TCommandResults> => {
|
|
250
|
+
const start = performance.now();
|
|
251
|
+
const result = await originalExec();
|
|
252
|
+
const end = performance.now();
|
|
253
|
+
const loggerResult = (end - start).toFixed(2);
|
|
254
|
+
// eslint-disable-next-line no-console
|
|
255
|
+
console.log(
|
|
256
|
+
`Latency for \u001B[38;2;19;185;39m${
|
|
257
|
+
this.multiExec ? ["MULTI-EXEC"] : ["PIPELINE"].toString().toUpperCase()
|
|
258
|
+
}\u001B[0m: \u001B[38;2;0;255;255m${loggerResult} ms\u001B[0m`
|
|
259
|
+
);
|
|
260
|
+
return result as TCommandResults;
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Send the pipeline request to upstash.
|
|
267
|
+
*
|
|
268
|
+
* Returns an array with the results of all pipelined commands.
|
|
269
|
+
*
|
|
270
|
+
* If all commands are statically chained from start to finish, types are inferred. You can still define a return type manually if necessary though:
|
|
271
|
+
* ```ts
|
|
272
|
+
* const p = redis.pipeline()
|
|
273
|
+
* p.get("key")
|
|
274
|
+
* const result = p.exec<[{ greeting: string }]>()
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
exec = async <
|
|
278
|
+
TCommandResults extends unknown[] = [] extends TCommands
|
|
279
|
+
? unknown[]
|
|
280
|
+
: InferResponseData<TCommands>,
|
|
281
|
+
>(): Promise<TCommandResults> => {
|
|
282
|
+
if (this.commands.length === 0) {
|
|
283
|
+
throw new Error("Pipeline is empty");
|
|
284
|
+
}
|
|
285
|
+
const path = this.multiExec ? ["multi-exec"] : ["pipeline"];
|
|
286
|
+
|
|
287
|
+
const res = (await this.client.request({
|
|
288
|
+
path,
|
|
289
|
+
body: Object.values(this.commands).map((c) => c.command),
|
|
290
|
+
})) as UpstashResponse<any>[];
|
|
291
|
+
|
|
292
|
+
return res.map(({ error, result }, i) => {
|
|
293
|
+
if (error) {
|
|
294
|
+
throw new UpstashError(
|
|
295
|
+
`Command ${i + 1} [ ${this.commands[i].command[0]} ] failed: ${error}`
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return this.commands[i].deserialize(result);
|
|
300
|
+
}) as TCommandResults;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Returns the length of pipeline before the execution
|
|
305
|
+
*/
|
|
306
|
+
length(): number {
|
|
307
|
+
return this.commands.length;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Pushes a command into the pipeline and returns a chainable instance of the
|
|
312
|
+
* pipeline
|
|
313
|
+
*/
|
|
314
|
+
private chain<T>(command: Command<any, T>): Pipeline<[...TCommands, Command<any, T>]> {
|
|
315
|
+
this.commands.push(command);
|
|
316
|
+
return this as any; // TS thinks we're returning Pipeline<[]> here, because we're not creating a new instance of the class, hence the cast
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* @see https://redis.io/commands/append
|
|
321
|
+
*/
|
|
322
|
+
append = (...args: CommandArgs<typeof AppendCommand>) =>
|
|
323
|
+
this.chain(new AppendCommand(args, this.commandOptions));
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* @see https://redis.io/commands/bitcount
|
|
327
|
+
*/
|
|
328
|
+
bitcount = (...args: CommandArgs<typeof BitCountCommand>) =>
|
|
329
|
+
this.chain(new BitCountCommand(args, this.commandOptions));
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Returns an instance that can be used to execute `BITFIELD` commands on one key.
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* ```typescript
|
|
336
|
+
* redis.set("mykey", 0);
|
|
337
|
+
* const result = await redis.pipeline()
|
|
338
|
+
* .bitfield("mykey")
|
|
339
|
+
* .set("u4", 0, 16)
|
|
340
|
+
* .incr("u4", "#1", 1)
|
|
341
|
+
* .exec();
|
|
342
|
+
* console.log(result); // [[0, 1]]
|
|
343
|
+
* ```
|
|
344
|
+
*
|
|
345
|
+
* @see https://redis.io/commands/bitfield
|
|
346
|
+
*/
|
|
347
|
+
bitfield = (...args: CommandArgs<typeof BitFieldCommand>) =>
|
|
348
|
+
new BitFieldCommand(args, this.client, this.commandOptions, this.chain.bind(this));
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* @see https://redis.io/commands/bitop
|
|
352
|
+
*/
|
|
353
|
+
bitop: {
|
|
354
|
+
(
|
|
355
|
+
op: "and" | "or" | "xor",
|
|
356
|
+
destinationKey: string,
|
|
357
|
+
sourceKey: string,
|
|
358
|
+
...sourceKeys: string[]
|
|
359
|
+
): Pipeline<[...TCommands, BitOpCommand]>;
|
|
360
|
+
(op: "not", destinationKey: string, sourceKey: string): Pipeline<[...TCommands, BitOpCommand]>;
|
|
361
|
+
} = (
|
|
362
|
+
op: "and" | "or" | "xor" | "not",
|
|
363
|
+
destinationKey: string,
|
|
364
|
+
sourceKey: string,
|
|
365
|
+
...sourceKeys: string[]
|
|
366
|
+
) =>
|
|
367
|
+
this.chain(
|
|
368
|
+
new BitOpCommand([op as any, destinationKey, sourceKey, ...sourceKeys], this.commandOptions)
|
|
369
|
+
);
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* @see https://redis.io/commands/bitpos
|
|
373
|
+
*/
|
|
374
|
+
bitpos = (...args: CommandArgs<typeof BitPosCommand>) =>
|
|
375
|
+
this.chain(new BitPosCommand(args, this.commandOptions));
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* @see https://redis.io/commands/copy
|
|
379
|
+
*/
|
|
380
|
+
copy = (...args: CommandArgs<typeof CopyCommand>) =>
|
|
381
|
+
this.chain(new CopyCommand(args, this.commandOptions));
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* @see https://redis.io/commands/zdiffstore
|
|
385
|
+
*/
|
|
386
|
+
zdiffstore = (...args: CommandArgs<typeof ZDiffStoreCommand>) =>
|
|
387
|
+
this.chain(new ZDiffStoreCommand(args, this.commandOptions));
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* @see https://redis.io/commands/dbsize
|
|
391
|
+
*/
|
|
392
|
+
dbsize = () => this.chain(new DBSizeCommand(this.commandOptions));
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* @see https://redis.io/commands/decr
|
|
396
|
+
*/
|
|
397
|
+
decr = (...args: CommandArgs<typeof DecrCommand>) =>
|
|
398
|
+
this.chain(new DecrCommand(args, this.commandOptions));
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* @see https://redis.io/commands/decrby
|
|
402
|
+
*/
|
|
403
|
+
decrby = (...args: CommandArgs<typeof DecrByCommand>) =>
|
|
404
|
+
this.chain(new DecrByCommand(args, this.commandOptions));
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* @see https://redis.io/commands/del
|
|
408
|
+
*/
|
|
409
|
+
del = (...args: CommandArgs<typeof DelCommand>) =>
|
|
410
|
+
this.chain(new DelCommand(args, this.commandOptions));
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* @see https://redis.io/commands/echo
|
|
414
|
+
*/
|
|
415
|
+
echo = (...args: CommandArgs<typeof EchoCommand>) =>
|
|
416
|
+
this.chain(new EchoCommand(args, this.commandOptions));
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* @see https://redis.io/commands/eval
|
|
420
|
+
*/
|
|
421
|
+
eval = <TArgs extends unknown[], TData = unknown>(
|
|
422
|
+
...args: [script: string, keys: string[], args: TArgs]
|
|
423
|
+
) => this.chain(new EvalCommand<TArgs, TData>(args, this.commandOptions));
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* @see https://redis.io/commands/evalsha
|
|
427
|
+
*/
|
|
428
|
+
evalsha = <TArgs extends unknown[], TData = unknown>(
|
|
429
|
+
...args: [sha1: string, keys: string[], args: TArgs]
|
|
430
|
+
) => this.chain(new EvalshaCommand<TArgs, TData>(args, this.commandOptions));
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* @see https://redis.io/commands/exists
|
|
434
|
+
*/
|
|
435
|
+
exists = (...args: CommandArgs<typeof ExistsCommand>) =>
|
|
436
|
+
this.chain(new ExistsCommand(args, this.commandOptions));
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* @see https://redis.io/commands/expire
|
|
440
|
+
*/
|
|
441
|
+
expire = (...args: CommandArgs<typeof ExpireCommand>) =>
|
|
442
|
+
this.chain(new ExpireCommand(args, this.commandOptions));
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* @see https://redis.io/commands/expireat
|
|
446
|
+
*/
|
|
447
|
+
expireat = (...args: CommandArgs<typeof ExpireAtCommand>) =>
|
|
448
|
+
this.chain(new ExpireAtCommand(args, this.commandOptions));
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* @see https://redis.io/commands/flushall
|
|
452
|
+
*/
|
|
453
|
+
flushall = (args?: CommandArgs<typeof FlushAllCommand>) =>
|
|
454
|
+
this.chain(new FlushAllCommand(args, this.commandOptions));
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* @see https://redis.io/commands/flushdb
|
|
458
|
+
*/
|
|
459
|
+
flushdb = (...args: CommandArgs<typeof FlushDBCommand>) =>
|
|
460
|
+
this.chain(new FlushDBCommand(args, this.commandOptions));
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* @see https://redis.io/commands/geoadd
|
|
464
|
+
*/
|
|
465
|
+
geoadd = <TData>(...args: CommandArgs<typeof GeoAddCommand<TData>>) =>
|
|
466
|
+
this.chain(new GeoAddCommand<TData>(args, this.commandOptions));
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* @see https://redis.io/commands/geodist
|
|
470
|
+
*/
|
|
471
|
+
geodist = <TData>(...args: CommandArgs<typeof GeoDistCommand<TData>>) =>
|
|
472
|
+
this.chain(new GeoDistCommand<TData>(args, this.commandOptions));
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* @see https://redis.io/commands/geopos
|
|
476
|
+
*/
|
|
477
|
+
geopos = <TData>(...args: CommandArgs<typeof GeoPosCommand<TData>>) =>
|
|
478
|
+
this.chain(new GeoPosCommand<TData>(args, this.commandOptions));
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* @see https://redis.io/commands/geohash
|
|
482
|
+
*/
|
|
483
|
+
geohash = <TData>(...args: CommandArgs<typeof GeoHashCommand<TData>>) =>
|
|
484
|
+
this.chain(new GeoHashCommand<TData>(args, this.commandOptions));
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* @see https://redis.io/commands/geosearch
|
|
488
|
+
*/
|
|
489
|
+
geosearch = <TData>(...args: CommandArgs<typeof GeoSearchCommand<TData>>) =>
|
|
490
|
+
this.chain(new GeoSearchCommand<TData>(args, this.commandOptions));
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* @see https://redis.io/commands/geosearchstore
|
|
494
|
+
*/
|
|
495
|
+
geosearchstore = <TData>(...args: CommandArgs<typeof GeoSearchStoreCommand<TData>>) =>
|
|
496
|
+
this.chain(new GeoSearchStoreCommand<TData>(args, this.commandOptions));
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* @see https://redis.io/commands/get
|
|
500
|
+
*/
|
|
501
|
+
get = <TData>(...args: CommandArgs<typeof GetCommand>) =>
|
|
502
|
+
this.chain(new GetCommand<TData>(args, this.commandOptions));
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* @see https://redis.io/commands/getbit
|
|
506
|
+
*/
|
|
507
|
+
getbit = (...args: CommandArgs<typeof GetBitCommand>) =>
|
|
508
|
+
this.chain(new GetBitCommand(args, this.commandOptions));
|
|
509
|
+
/**
|
|
510
|
+
* @see https://redis.io/commands/getdel
|
|
511
|
+
*/
|
|
512
|
+
getdel = <TData>(...args: CommandArgs<typeof GetDelCommand>) =>
|
|
513
|
+
this.chain(new GetDelCommand<TData>(args, this.commandOptions));
|
|
514
|
+
/**
|
|
515
|
+
* @see https://redis.io/commands/getrange
|
|
516
|
+
*/
|
|
517
|
+
getrange = (...args: CommandArgs<typeof GetRangeCommand>) =>
|
|
518
|
+
this.chain(new GetRangeCommand(args, this.commandOptions));
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* @see https://redis.io/commands/getset
|
|
522
|
+
*/
|
|
523
|
+
getset = <TData>(key: string, value: TData) =>
|
|
524
|
+
this.chain(new GetSetCommand<TData>([key, value], this.commandOptions));
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* @see https://redis.io/commands/hdel
|
|
528
|
+
*/
|
|
529
|
+
hdel = (...args: CommandArgs<typeof HDelCommand>) =>
|
|
530
|
+
this.chain(new HDelCommand(args, this.commandOptions));
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* @see https://redis.io/commands/hexists
|
|
534
|
+
*/
|
|
535
|
+
hexists = (...args: CommandArgs<typeof HExistsCommand>) =>
|
|
536
|
+
this.chain(new HExistsCommand(args, this.commandOptions));
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* @see https://redis.io/commands/hget
|
|
540
|
+
*/
|
|
541
|
+
hget = <TData>(...args: CommandArgs<typeof HGetCommand>) =>
|
|
542
|
+
this.chain(new HGetCommand<TData>(args, this.commandOptions));
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* @see https://redis.io/commands/hgetall
|
|
546
|
+
*/
|
|
547
|
+
hgetall = <TData extends Record<string, unknown>>(...args: CommandArgs<typeof HGetAllCommand>) =>
|
|
548
|
+
this.chain(new HGetAllCommand<TData>(args, this.commandOptions));
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* @see https://redis.io/commands/hincrby
|
|
552
|
+
*/
|
|
553
|
+
hincrby = (...args: CommandArgs<typeof HIncrByCommand>) =>
|
|
554
|
+
this.chain(new HIncrByCommand(args, this.commandOptions));
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* @see https://redis.io/commands/hincrbyfloat
|
|
558
|
+
*/
|
|
559
|
+
hincrbyfloat = (...args: CommandArgs<typeof HIncrByFloatCommand>) =>
|
|
560
|
+
this.chain(new HIncrByFloatCommand(args, this.commandOptions));
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* @see https://redis.io/commands/hkeys
|
|
564
|
+
*/
|
|
565
|
+
hkeys = (...args: CommandArgs<typeof HKeysCommand>) =>
|
|
566
|
+
this.chain(new HKeysCommand(args, this.commandOptions));
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* @see https://redis.io/commands/hlen
|
|
570
|
+
*/
|
|
571
|
+
hlen = (...args: CommandArgs<typeof HLenCommand>) =>
|
|
572
|
+
this.chain(new HLenCommand(args, this.commandOptions));
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* @see https://redis.io/commands/hmget
|
|
576
|
+
*/
|
|
577
|
+
hmget = <TData extends Record<string, unknown>>(...args: CommandArgs<typeof HMGetCommand>) =>
|
|
578
|
+
this.chain(new HMGetCommand<TData>(args, this.commandOptions));
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* @see https://redis.io/commands/hmset
|
|
582
|
+
*/
|
|
583
|
+
hmset = <TData>(key: string, kv: Record<string, TData>) =>
|
|
584
|
+
this.chain(new HMSetCommand([key, kv], this.commandOptions));
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* @see https://redis.io/commands/hrandfield
|
|
588
|
+
*/
|
|
589
|
+
hrandfield = <TData extends string | string[] | Record<string, unknown>>(
|
|
590
|
+
key: string,
|
|
591
|
+
count?: number,
|
|
592
|
+
withValues?: boolean
|
|
593
|
+
) =>
|
|
594
|
+
this.chain(new HRandFieldCommand<TData>([key, count, withValues] as any, this.commandOptions));
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* @see https://redis.io/commands/hscan
|
|
598
|
+
*/
|
|
599
|
+
hscan = (...args: CommandArgs<typeof HScanCommand>) =>
|
|
600
|
+
this.chain(new HScanCommand(args, this.commandOptions));
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* @see https://redis.io/commands/hset
|
|
604
|
+
*/
|
|
605
|
+
hset = <TData>(key: string, kv: Record<string, TData>) =>
|
|
606
|
+
this.chain(new HSetCommand<TData>([key, kv], this.commandOptions));
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* @see https://redis.io/commands/hsetnx
|
|
610
|
+
*/
|
|
611
|
+
hsetnx = <TData>(key: string, field: string, value: TData) =>
|
|
612
|
+
this.chain(new HSetNXCommand<TData>([key, field, value], this.commandOptions));
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* @see https://redis.io/commands/hstrlen
|
|
616
|
+
*/
|
|
617
|
+
hstrlen = (...args: CommandArgs<typeof HStrLenCommand>) =>
|
|
618
|
+
this.chain(new HStrLenCommand(args, this.commandOptions));
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* @see https://redis.io/commands/hvals
|
|
622
|
+
*/
|
|
623
|
+
hvals = (...args: CommandArgs<typeof HValsCommand>) =>
|
|
624
|
+
this.chain(new HValsCommand(args, this.commandOptions));
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* @see https://redis.io/commands/incr
|
|
628
|
+
*/
|
|
629
|
+
incr = (...args: CommandArgs<typeof IncrCommand>) =>
|
|
630
|
+
this.chain(new IncrCommand(args, this.commandOptions));
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* @see https://redis.io/commands/incrby
|
|
634
|
+
*/
|
|
635
|
+
incrby = (...args: CommandArgs<typeof IncrByCommand>) =>
|
|
636
|
+
this.chain(new IncrByCommand(args, this.commandOptions));
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* @see https://redis.io/commands/incrbyfloat
|
|
640
|
+
*/
|
|
641
|
+
incrbyfloat = (...args: CommandArgs<typeof IncrByFloatCommand>) =>
|
|
642
|
+
this.chain(new IncrByFloatCommand(args, this.commandOptions));
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* @see https://redis.io/commands/keys
|
|
646
|
+
*/
|
|
647
|
+
keys = (...args: CommandArgs<typeof KeysCommand>) =>
|
|
648
|
+
this.chain(new KeysCommand(args, this.commandOptions));
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* @see https://redis.io/commands/lindex
|
|
652
|
+
*/
|
|
653
|
+
lindex = (...args: CommandArgs<typeof LIndexCommand>) =>
|
|
654
|
+
this.chain(new LIndexCommand(args, this.commandOptions));
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* @see https://redis.io/commands/linsert
|
|
658
|
+
*/
|
|
659
|
+
linsert = <TData>(key: string, direction: "before" | "after", pivot: TData, value: TData) =>
|
|
660
|
+
this.chain(new LInsertCommand<TData>([key, direction, pivot, value], this.commandOptions));
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* @see https://redis.io/commands/llen
|
|
664
|
+
*/
|
|
665
|
+
llen = (...args: CommandArgs<typeof LLenCommand>) =>
|
|
666
|
+
this.chain(new LLenCommand(args, this.commandOptions));
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* @see https://redis.io/commands/lmove
|
|
670
|
+
*/
|
|
671
|
+
lmove = <TData = string>(...args: CommandArgs<typeof LMoveCommand>) =>
|
|
672
|
+
this.chain(new LMoveCommand<TData>(args, this.commandOptions));
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* @see https://redis.io/commands/lpop
|
|
676
|
+
*/
|
|
677
|
+
lpop = <TData>(...args: CommandArgs<typeof LPopCommand>) =>
|
|
678
|
+
this.chain(new LPopCommand<TData>(args, this.commandOptions));
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* @see https://redis.io/commands/lmpop
|
|
682
|
+
*/
|
|
683
|
+
lmpop = <TData>(...args: CommandArgs<typeof LmPopCommand>) =>
|
|
684
|
+
this.chain(new LmPopCommand<TData>(args, this.commandOptions));
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* @see https://redis.io/commands/lpos
|
|
688
|
+
*/
|
|
689
|
+
lpos = <TData>(...args: CommandArgs<typeof LPosCommand>) =>
|
|
690
|
+
this.chain(new LPosCommand<TData>(args, this.commandOptions));
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* @see https://redis.io/commands/lpush
|
|
694
|
+
*/
|
|
695
|
+
lpush = <TData>(key: string, ...elements: TData[]) =>
|
|
696
|
+
this.chain(new LPushCommand<TData>([key, ...elements], this.commandOptions));
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* @see https://redis.io/commands/lpushx
|
|
700
|
+
*/
|
|
701
|
+
lpushx = <TData>(key: string, ...elements: TData[]) =>
|
|
702
|
+
this.chain(new LPushXCommand<TData>([key, ...elements], this.commandOptions));
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* @see https://redis.io/commands/lrange
|
|
706
|
+
*/
|
|
707
|
+
lrange = <TResult = string>(...args: CommandArgs<typeof LRangeCommand>) =>
|
|
708
|
+
this.chain(new LRangeCommand<TResult>(args, this.commandOptions));
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* @see https://redis.io/commands/lrem
|
|
712
|
+
*/
|
|
713
|
+
lrem = <TData>(key: string, count: number, value: TData) =>
|
|
714
|
+
this.chain(new LRemCommand([key, count, value], this.commandOptions));
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* @see https://redis.io/commands/lset
|
|
718
|
+
*/
|
|
719
|
+
lset = <TData>(key: string, index: number, value: TData) =>
|
|
720
|
+
this.chain(new LSetCommand([key, index, value], this.commandOptions));
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* @see https://redis.io/commands/ltrim
|
|
724
|
+
*/
|
|
725
|
+
ltrim = (...args: CommandArgs<typeof LTrimCommand>) =>
|
|
726
|
+
this.chain(new LTrimCommand(args, this.commandOptions));
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* @see https://redis.io/commands/mget
|
|
730
|
+
*/
|
|
731
|
+
mget = <TData extends unknown[]>(...args: CommandArgs<typeof MGetCommand>) =>
|
|
732
|
+
this.chain(new MGetCommand<TData>(args, this.commandOptions));
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* @see https://redis.io/commands/mset
|
|
736
|
+
*/
|
|
737
|
+
mset = <TData>(kv: Record<string, TData>) =>
|
|
738
|
+
this.chain(new MSetCommand<TData>([kv], this.commandOptions));
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* @see https://redis.io/commands/msetnx
|
|
742
|
+
*/
|
|
743
|
+
msetnx = <TData>(kv: Record<string, TData>) =>
|
|
744
|
+
this.chain(new MSetNXCommand<TData>([kv], this.commandOptions));
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* @see https://redis.io/commands/persist
|
|
748
|
+
*/
|
|
749
|
+
persist = (...args: CommandArgs<typeof PersistCommand>) =>
|
|
750
|
+
this.chain(new PersistCommand(args, this.commandOptions));
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* @see https://redis.io/commands/pexpire
|
|
754
|
+
*/
|
|
755
|
+
pexpire = (...args: CommandArgs<typeof PExpireCommand>) =>
|
|
756
|
+
this.chain(new PExpireCommand(args, this.commandOptions));
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* @see https://redis.io/commands/pexpireat
|
|
760
|
+
*/
|
|
761
|
+
pexpireat = (...args: CommandArgs<typeof PExpireAtCommand>) =>
|
|
762
|
+
this.chain(new PExpireAtCommand(args, this.commandOptions));
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* @see https://redis.io/commands/pfadd
|
|
766
|
+
*/
|
|
767
|
+
pfadd = (...args: CommandArgs<typeof PfAddCommand>) =>
|
|
768
|
+
this.chain(new PfAddCommand(args, this.commandOptions));
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* @see https://redis.io/commands/pfcount
|
|
772
|
+
*/
|
|
773
|
+
pfcount = (...args: CommandArgs<typeof PfCountCommand>) =>
|
|
774
|
+
this.chain(new PfCountCommand(args, this.commandOptions));
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* @see https://redis.io/commands/pfmerge
|
|
778
|
+
*/
|
|
779
|
+
pfmerge = (...args: CommandArgs<typeof PfMergeCommand>) =>
|
|
780
|
+
this.chain(new PfMergeCommand(args, this.commandOptions));
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* @see https://redis.io/commands/ping
|
|
784
|
+
*/
|
|
785
|
+
ping = (args?: CommandArgs<typeof PingCommand>) =>
|
|
786
|
+
this.chain(new PingCommand(args, this.commandOptions));
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* @see https://redis.io/commands/psetex
|
|
790
|
+
*/
|
|
791
|
+
psetex = <TData>(key: string, ttl: number, value: TData) =>
|
|
792
|
+
this.chain(new PSetEXCommand<TData>([key, ttl, value], this.commandOptions));
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* @see https://redis.io/commands/pttl
|
|
796
|
+
*/
|
|
797
|
+
pttl = (...args: CommandArgs<typeof PTtlCommand>) =>
|
|
798
|
+
this.chain(new PTtlCommand(args, this.commandOptions));
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* @see https://redis.io/commands/publish
|
|
802
|
+
*/
|
|
803
|
+
publish = (...args: CommandArgs<typeof PublishCommand>) =>
|
|
804
|
+
this.chain(new PublishCommand(args, this.commandOptions));
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* @see https://redis.io/commands/randomkey
|
|
808
|
+
*/
|
|
809
|
+
randomkey = () => this.chain(new RandomKeyCommand(this.commandOptions));
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* @see https://redis.io/commands/rename
|
|
813
|
+
*/
|
|
814
|
+
rename = (...args: CommandArgs<typeof RenameCommand>) =>
|
|
815
|
+
this.chain(new RenameCommand(args, this.commandOptions));
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* @see https://redis.io/commands/renamenx
|
|
819
|
+
*/
|
|
820
|
+
renamenx = (...args: CommandArgs<typeof RenameNXCommand>) =>
|
|
821
|
+
this.chain(new RenameNXCommand(args, this.commandOptions));
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* @see https://redis.io/commands/rpop
|
|
825
|
+
*/
|
|
826
|
+
rpop = <TData = string>(...args: CommandArgs<typeof RPopCommand>) =>
|
|
827
|
+
this.chain(new RPopCommand<TData>(args, this.commandOptions));
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* @see https://redis.io/commands/rpush
|
|
831
|
+
*/
|
|
832
|
+
rpush = <TData>(key: string, ...elements: TData[]) =>
|
|
833
|
+
this.chain(new RPushCommand([key, ...elements], this.commandOptions));
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* @see https://redis.io/commands/rpushx
|
|
837
|
+
*/
|
|
838
|
+
rpushx = <TData>(key: string, ...elements: TData[]) =>
|
|
839
|
+
this.chain(new RPushXCommand([key, ...elements], this.commandOptions));
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* @see https://redis.io/commands/sadd
|
|
843
|
+
*/
|
|
844
|
+
sadd = <TData>(key: string, member: TData, ...members: TData[]) =>
|
|
845
|
+
this.chain(new SAddCommand<TData>([key, member, ...members], this.commandOptions));
|
|
846
|
+
|
|
847
|
+
/**
|
|
848
|
+
* @see https://redis.io/commands/scan
|
|
849
|
+
*/
|
|
850
|
+
scan = (...args: CommandArgs<typeof ScanCommand>) =>
|
|
851
|
+
this.chain(new ScanCommand(args, this.commandOptions));
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* @see https://redis.io/commands/scard
|
|
855
|
+
*/
|
|
856
|
+
scard = (...args: CommandArgs<typeof SCardCommand>) =>
|
|
857
|
+
this.chain(new SCardCommand(args, this.commandOptions));
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* @see https://redis.io/commands/script-exists
|
|
861
|
+
*/
|
|
862
|
+
scriptExists = (...args: CommandArgs<typeof ScriptExistsCommand>) =>
|
|
863
|
+
this.chain(new ScriptExistsCommand(args, this.commandOptions));
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* @see https://redis.io/commands/script-flush
|
|
867
|
+
*/
|
|
868
|
+
scriptFlush = (...args: CommandArgs<typeof ScriptFlushCommand>) =>
|
|
869
|
+
this.chain(new ScriptFlushCommand(args, this.commandOptions));
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* @see https://redis.io/commands/script-load
|
|
873
|
+
*/
|
|
874
|
+
scriptLoad = (...args: CommandArgs<typeof ScriptLoadCommand>) =>
|
|
875
|
+
this.chain(new ScriptLoadCommand(args, this.commandOptions));
|
|
876
|
+
/*)*
|
|
877
|
+
* @see https://redis.io/commands/sdiff
|
|
878
|
+
*/
|
|
879
|
+
sdiff = (...args: CommandArgs<typeof SDiffCommand>) =>
|
|
880
|
+
this.chain(new SDiffCommand(args, this.commandOptions));
|
|
881
|
+
|
|
882
|
+
/**
|
|
883
|
+
* @see https://redis.io/commands/sdiffstore
|
|
884
|
+
*/
|
|
885
|
+
sdiffstore = (...args: CommandArgs<typeof SDiffStoreCommand>) =>
|
|
886
|
+
this.chain(new SDiffStoreCommand(args, this.commandOptions));
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* @see https://redis.io/commands/set
|
|
890
|
+
*/
|
|
891
|
+
set = <TData>(key: string, value: TData, opts?: SetCommandOptions) =>
|
|
892
|
+
this.chain(new SetCommand<TData>([key, value, opts], this.commandOptions));
|
|
893
|
+
|
|
894
|
+
/**
|
|
895
|
+
* @see https://redis.io/commands/setbit
|
|
896
|
+
*/
|
|
897
|
+
setbit = (...args: CommandArgs<typeof SetBitCommand>) =>
|
|
898
|
+
this.chain(new SetBitCommand(args, this.commandOptions));
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* @see https://redis.io/commands/setex
|
|
902
|
+
*/
|
|
903
|
+
setex = <TData>(key: string, ttl: number, value: TData) =>
|
|
904
|
+
this.chain(new SetExCommand<TData>([key, ttl, value], this.commandOptions));
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* @see https://redis.io/commands/setnx
|
|
908
|
+
*/
|
|
909
|
+
setnx = <TData>(key: string, value: TData) =>
|
|
910
|
+
this.chain(new SetNxCommand<TData>([key, value], this.commandOptions));
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* @see https://redis.io/commands/setrange
|
|
914
|
+
*/
|
|
915
|
+
setrange = (...args: CommandArgs<typeof SetRangeCommand>) =>
|
|
916
|
+
this.chain(new SetRangeCommand(args, this.commandOptions));
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* @see https://redis.io/commands/sinter
|
|
920
|
+
*/
|
|
921
|
+
sinter = (...args: CommandArgs<typeof SInterCommand>) =>
|
|
922
|
+
this.chain(new SInterCommand(args, this.commandOptions));
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* @see https://redis.io/commands/sinterstore
|
|
926
|
+
*/
|
|
927
|
+
sinterstore = (...args: CommandArgs<typeof SInterStoreCommand>) =>
|
|
928
|
+
this.chain(new SInterStoreCommand(args, this.commandOptions));
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* @see https://redis.io/commands/sismember
|
|
932
|
+
*/
|
|
933
|
+
sismember = <TData>(key: string, member: TData) =>
|
|
934
|
+
this.chain(new SIsMemberCommand<TData>([key, member], this.commandOptions));
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* @see https://redis.io/commands/smembers
|
|
938
|
+
*/
|
|
939
|
+
smembers = <TData extends unknown[] = string[]>(...args: CommandArgs<typeof SMembersCommand>) =>
|
|
940
|
+
this.chain(new SMembersCommand<TData>(args, this.commandOptions));
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* @see https://redis.io/commands/smismember
|
|
944
|
+
*/
|
|
945
|
+
smismember = <TMembers extends unknown[]>(key: string, members: TMembers) =>
|
|
946
|
+
this.chain(new SMIsMemberCommand<TMembers>([key, members], this.commandOptions));
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* @see https://redis.io/commands/smove
|
|
950
|
+
*/
|
|
951
|
+
smove = <TData>(source: string, destination: string, member: TData) =>
|
|
952
|
+
this.chain(new SMoveCommand<TData>([source, destination, member], this.commandOptions));
|
|
953
|
+
|
|
954
|
+
/**
|
|
955
|
+
* @see https://redis.io/commands/spop
|
|
956
|
+
*/
|
|
957
|
+
spop = <TData>(...args: CommandArgs<typeof SPopCommand>) =>
|
|
958
|
+
this.chain(new SPopCommand<TData>(args, this.commandOptions));
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* @see https://redis.io/commands/srandmember
|
|
962
|
+
*/
|
|
963
|
+
srandmember = <TData>(...args: CommandArgs<typeof SRandMemberCommand>) =>
|
|
964
|
+
this.chain(new SRandMemberCommand<TData>(args, this.commandOptions));
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* @see https://redis.io/commands/srem
|
|
968
|
+
*/
|
|
969
|
+
srem = <TData>(key: string, ...members: TData[]) =>
|
|
970
|
+
this.chain(new SRemCommand<TData>([key, ...members], this.commandOptions));
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* @see https://redis.io/commands/sscan
|
|
974
|
+
*/
|
|
975
|
+
sscan = (...args: CommandArgs<typeof SScanCommand>) =>
|
|
976
|
+
this.chain(new SScanCommand(args, this.commandOptions));
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* @see https://redis.io/commands/strlen
|
|
980
|
+
*/
|
|
981
|
+
strlen = (...args: CommandArgs<typeof StrLenCommand>) =>
|
|
982
|
+
this.chain(new StrLenCommand(args, this.commandOptions));
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* @see https://redis.io/commands/sunion
|
|
986
|
+
*/
|
|
987
|
+
sunion = (...args: CommandArgs<typeof SUnionCommand>) =>
|
|
988
|
+
this.chain(new SUnionCommand(args, this.commandOptions));
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* @see https://redis.io/commands/sunionstore
|
|
992
|
+
*/
|
|
993
|
+
sunionstore = (...args: CommandArgs<typeof SUnionStoreCommand>) =>
|
|
994
|
+
this.chain(new SUnionStoreCommand(args, this.commandOptions));
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* @see https://redis.io/commands/time
|
|
998
|
+
*/
|
|
999
|
+
time = () => this.chain(new TimeCommand(this.commandOptions));
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* @see https://redis.io/commands/touch
|
|
1003
|
+
*/
|
|
1004
|
+
touch = (...args: CommandArgs<typeof TouchCommand>) =>
|
|
1005
|
+
this.chain(new TouchCommand(args, this.commandOptions));
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* @see https://redis.io/commands/ttl
|
|
1009
|
+
*/
|
|
1010
|
+
ttl = (...args: CommandArgs<typeof TtlCommand>) =>
|
|
1011
|
+
this.chain(new TtlCommand(args, this.commandOptions));
|
|
1012
|
+
|
|
1013
|
+
/**
|
|
1014
|
+
* @see https://redis.io/commands/type
|
|
1015
|
+
*/
|
|
1016
|
+
type = (...args: CommandArgs<typeof TypeCommand>) =>
|
|
1017
|
+
this.chain(new TypeCommand(args, this.commandOptions));
|
|
1018
|
+
|
|
1019
|
+
/**
|
|
1020
|
+
* @see https://redis.io/commands/unlink
|
|
1021
|
+
*/
|
|
1022
|
+
unlink = (...args: CommandArgs<typeof UnlinkCommand>) =>
|
|
1023
|
+
this.chain(new UnlinkCommand(args, this.commandOptions));
|
|
1024
|
+
|
|
1025
|
+
/**
|
|
1026
|
+
* @see https://redis.io/commands/zadd
|
|
1027
|
+
*/
|
|
1028
|
+
zadd = <TData>(
|
|
1029
|
+
...args:
|
|
1030
|
+
| [key: string, scoreMember: ScoreMember<TData>, ...scoreMemberPairs: ScoreMember<TData>[]]
|
|
1031
|
+
| [
|
|
1032
|
+
key: string,
|
|
1033
|
+
opts: ZAddCommandOptions,
|
|
1034
|
+
...scoreMemberPairs: [ScoreMember<TData>, ...ScoreMember<TData>[]],
|
|
1035
|
+
]
|
|
1036
|
+
) => {
|
|
1037
|
+
if ("score" in args[1]) {
|
|
1038
|
+
return this.chain(
|
|
1039
|
+
new ZAddCommand<TData>([args[0], args[1], ...(args.slice(2) as any)], this.commandOptions)
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
return this.chain(
|
|
1044
|
+
new ZAddCommand<TData>(
|
|
1045
|
+
[args[0], args[1] as any, ...(args.slice(2) as any)],
|
|
1046
|
+
this.commandOptions
|
|
1047
|
+
)
|
|
1048
|
+
);
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* @see https://redis.io/commands/xadd
|
|
1053
|
+
*/
|
|
1054
|
+
xadd = (...args: CommandArgs<typeof XAddCommand>) =>
|
|
1055
|
+
this.chain(new XAddCommand(args, this.commandOptions));
|
|
1056
|
+
|
|
1057
|
+
/**
|
|
1058
|
+
* @see https://redis.io/commands/xack
|
|
1059
|
+
*/
|
|
1060
|
+
xack = (...args: CommandArgs<typeof XAckCommand>) =>
|
|
1061
|
+
this.chain(new XAckCommand(args, this.commandOptions));
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* @see https://redis.io/commands/xdel
|
|
1065
|
+
*/
|
|
1066
|
+
xdel = (...args: CommandArgs<typeof XDelCommand>) =>
|
|
1067
|
+
this.chain(new XDelCommand(args, this.commandOptions));
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* @see https://redis.io/commands/xgroup
|
|
1071
|
+
*/
|
|
1072
|
+
xgroup = (...args: CommandArgs<typeof XGroupCommand>) =>
|
|
1073
|
+
this.chain(new XGroupCommand(args, this.commandOptions));
|
|
1074
|
+
|
|
1075
|
+
/**
|
|
1076
|
+
* @see https://redis.io/commands/xread
|
|
1077
|
+
*/
|
|
1078
|
+
xread = (...args: CommandArgs<typeof XReadCommand>) =>
|
|
1079
|
+
this.chain(new XReadCommand(args, this.commandOptions));
|
|
1080
|
+
|
|
1081
|
+
/**
|
|
1082
|
+
* @see https://redis.io/commands/xreadgroup
|
|
1083
|
+
*/
|
|
1084
|
+
xreadgroup = (...args: CommandArgs<typeof XReadGroupCommand>) =>
|
|
1085
|
+
this.chain(new XReadGroupCommand(args, this.commandOptions));
|
|
1086
|
+
|
|
1087
|
+
/**
|
|
1088
|
+
* @see https://redis.io/commands/xinfo
|
|
1089
|
+
*/
|
|
1090
|
+
xinfo = (...args: CommandArgs<typeof XInfoCommand>) =>
|
|
1091
|
+
this.chain(new XInfoCommand(args, this.commandOptions));
|
|
1092
|
+
|
|
1093
|
+
/**
|
|
1094
|
+
* @see https://redis.io/commands/xlen
|
|
1095
|
+
*/
|
|
1096
|
+
xlen = (...args: CommandArgs<typeof XLenCommand>) =>
|
|
1097
|
+
this.chain(new XLenCommand(args, this.commandOptions));
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
* @see https://redis.io/commands/xpending
|
|
1101
|
+
*/
|
|
1102
|
+
xpending = (...args: CommandArgs<typeof XPendingCommand>) =>
|
|
1103
|
+
this.chain(new XPendingCommand(args, this.commandOptions));
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* @see https://redis.io/commands/xclaim
|
|
1107
|
+
*/
|
|
1108
|
+
xclaim = (...args: CommandArgs<typeof XClaimCommand>) =>
|
|
1109
|
+
this.chain(new XClaimCommand(args, this.commandOptions));
|
|
1110
|
+
|
|
1111
|
+
/**
|
|
1112
|
+
* @see https://redis.io/commands/xautoclaim
|
|
1113
|
+
*/
|
|
1114
|
+
xautoclaim = (...args: CommandArgs<typeof XAutoClaim>) =>
|
|
1115
|
+
this.chain(new XAutoClaim(args, this.commandOptions));
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* @see https://redis.io/commands/xtrim
|
|
1119
|
+
*/
|
|
1120
|
+
xtrim = (...args: CommandArgs<typeof XTrimCommand>) =>
|
|
1121
|
+
this.chain(new XTrimCommand(args, this.commandOptions));
|
|
1122
|
+
|
|
1123
|
+
/**
|
|
1124
|
+
* @see https://redis.io/commands/xrange
|
|
1125
|
+
*/
|
|
1126
|
+
xrange = (...args: CommandArgs<typeof XRangeCommand>) =>
|
|
1127
|
+
this.chain(new XRangeCommand(args, this.commandOptions));
|
|
1128
|
+
|
|
1129
|
+
/**
|
|
1130
|
+
* @see https://redis.io/commands/xrevrange
|
|
1131
|
+
*/
|
|
1132
|
+
xrevrange = (...args: CommandArgs<typeof XRevRangeCommand>) =>
|
|
1133
|
+
this.chain(new XRevRangeCommand(args, this.commandOptions));
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* @see https://redis.io/commands/zcard
|
|
1137
|
+
*/
|
|
1138
|
+
zcard = (...args: CommandArgs<typeof ZCardCommand>) =>
|
|
1139
|
+
this.chain(new ZCardCommand(args, this.commandOptions));
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
* @see https://redis.io/commands/zcount
|
|
1143
|
+
*/
|
|
1144
|
+
zcount = (...args: CommandArgs<typeof ZCountCommand>) =>
|
|
1145
|
+
this.chain(new ZCountCommand(args, this.commandOptions));
|
|
1146
|
+
|
|
1147
|
+
/**
|
|
1148
|
+
* @see https://redis.io/commands/zincrby
|
|
1149
|
+
*/
|
|
1150
|
+
zincrby = <TData>(key: string, increment: number, member: TData) =>
|
|
1151
|
+
this.chain(new ZIncrByCommand<TData>([key, increment, member], this.commandOptions));
|
|
1152
|
+
|
|
1153
|
+
/**
|
|
1154
|
+
* @see https://redis.io/commands/zinterstore
|
|
1155
|
+
*/
|
|
1156
|
+
zinterstore = (...args: CommandArgs<typeof ZInterStoreCommand>) =>
|
|
1157
|
+
this.chain(new ZInterStoreCommand(args, this.commandOptions));
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* @see https://redis.io/commands/zlexcount
|
|
1161
|
+
*/
|
|
1162
|
+
zlexcount = (...args: CommandArgs<typeof ZLexCountCommand>) =>
|
|
1163
|
+
this.chain(new ZLexCountCommand(args, this.commandOptions));
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* @see https://redis.io/commands/zmscore
|
|
1167
|
+
*/
|
|
1168
|
+
zmscore = (...args: CommandArgs<typeof ZMScoreCommand>) =>
|
|
1169
|
+
this.chain(new ZMScoreCommand(args, this.commandOptions));
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* @see https://redis.io/commands/zpopmax
|
|
1173
|
+
*/
|
|
1174
|
+
zpopmax = <TData>(...args: CommandArgs<typeof ZPopMaxCommand>) =>
|
|
1175
|
+
this.chain(new ZPopMaxCommand<TData>(args, this.commandOptions));
|
|
1176
|
+
|
|
1177
|
+
/**
|
|
1178
|
+
* @see https://redis.io/commands/zpopmin
|
|
1179
|
+
*/
|
|
1180
|
+
zpopmin = <TData>(...args: CommandArgs<typeof ZPopMinCommand>) =>
|
|
1181
|
+
this.chain(new ZPopMinCommand<TData>(args, this.commandOptions));
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* @see https://redis.io/commands/zrange
|
|
1185
|
+
*/
|
|
1186
|
+
zrange = <TData extends unknown[]>(
|
|
1187
|
+
...args:
|
|
1188
|
+
| [key: string, min: number, max: number, opts?: ZRangeCommandOptions]
|
|
1189
|
+
| [
|
|
1190
|
+
key: string,
|
|
1191
|
+
min: `(${string}` | `[${string}` | "-" | "+",
|
|
1192
|
+
max: `(${string}` | `[${string}` | "-" | "+",
|
|
1193
|
+
opts: { byLex: true } & ZRangeCommandOptions,
|
|
1194
|
+
]
|
|
1195
|
+
| [
|
|
1196
|
+
key: string,
|
|
1197
|
+
min: number | `(${number}` | "-inf" | "+inf",
|
|
1198
|
+
max: number | `(${number}` | "-inf" | "+inf",
|
|
1199
|
+
opts: { byScore: true } & ZRangeCommandOptions,
|
|
1200
|
+
]
|
|
1201
|
+
) => this.chain(new ZRangeCommand<TData>(args as any, this.commandOptions));
|
|
1202
|
+
|
|
1203
|
+
/**
|
|
1204
|
+
* @see https://redis.io/commands/zrank
|
|
1205
|
+
*/
|
|
1206
|
+
zrank = <TData>(key: string, member: TData) =>
|
|
1207
|
+
this.chain(new ZRankCommand<TData>([key, member], this.commandOptions));
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* @see https://redis.io/commands/zrem
|
|
1211
|
+
*/
|
|
1212
|
+
zrem = <TData>(key: string, ...members: TData[]) =>
|
|
1213
|
+
this.chain(new ZRemCommand<TData>([key, ...members], this.commandOptions));
|
|
1214
|
+
|
|
1215
|
+
/**
|
|
1216
|
+
* @see https://redis.io/commands/zremrangebylex
|
|
1217
|
+
*/
|
|
1218
|
+
zremrangebylex = (...args: CommandArgs<typeof ZRemRangeByLexCommand>) =>
|
|
1219
|
+
this.chain(new ZRemRangeByLexCommand(args, this.commandOptions));
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1222
|
+
* @see https://redis.io/commands/zremrangebyrank
|
|
1223
|
+
*/
|
|
1224
|
+
zremrangebyrank = (...args: CommandArgs<typeof ZRemRangeByRankCommand>) =>
|
|
1225
|
+
this.chain(new ZRemRangeByRankCommand(args, this.commandOptions));
|
|
1226
|
+
|
|
1227
|
+
/**
|
|
1228
|
+
* @see https://redis.io/commands/zremrangebyscore
|
|
1229
|
+
*/
|
|
1230
|
+
zremrangebyscore = (...args: CommandArgs<typeof ZRemRangeByScoreCommand>) =>
|
|
1231
|
+
this.chain(new ZRemRangeByScoreCommand(args, this.commandOptions));
|
|
1232
|
+
|
|
1233
|
+
/**
|
|
1234
|
+
* @see https://redis.io/commands/zrevrank
|
|
1235
|
+
*/
|
|
1236
|
+
zrevrank = <TData>(key: string, member: TData) =>
|
|
1237
|
+
this.chain(new ZRevRankCommand<TData>([key, member], this.commandOptions));
|
|
1238
|
+
|
|
1239
|
+
/**
|
|
1240
|
+
* @see https://redis.io/commands/zscan
|
|
1241
|
+
*/
|
|
1242
|
+
zscan = (...args: CommandArgs<typeof ZScanCommand>) =>
|
|
1243
|
+
this.chain(new ZScanCommand(args, this.commandOptions));
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* @see https://redis.io/commands/zscore
|
|
1247
|
+
*/
|
|
1248
|
+
zscore = <TData>(key: string, member: TData) =>
|
|
1249
|
+
this.chain(new ZScoreCommand<TData>([key, member], this.commandOptions));
|
|
1250
|
+
|
|
1251
|
+
/**
|
|
1252
|
+
* @see https://redis.io/commands/zunionstore
|
|
1253
|
+
*/
|
|
1254
|
+
zunionstore = (...args: CommandArgs<typeof ZUnionStoreCommand>) =>
|
|
1255
|
+
this.chain(new ZUnionStoreCommand(args, this.commandOptions));
|
|
1256
|
+
|
|
1257
|
+
/**
|
|
1258
|
+
* @see https://redis.io/commands/zunion
|
|
1259
|
+
*/
|
|
1260
|
+
zunion = (...args: CommandArgs<typeof ZUnionCommand>) =>
|
|
1261
|
+
this.chain(new ZUnionCommand(args, this.commandOptions));
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* @see https://redis.io/commands/?group=json
|
|
1265
|
+
*/
|
|
1266
|
+
get json() {
|
|
1267
|
+
return {
|
|
1268
|
+
/**
|
|
1269
|
+
* @see https://redis.io/commands/json.arrappend
|
|
1270
|
+
*/
|
|
1271
|
+
arrappend: (...args: CommandArgs<typeof JsonArrAppendCommand>) =>
|
|
1272
|
+
this.chain(new JsonArrAppendCommand(args, this.commandOptions)),
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* @see https://redis.io/commands/json.arrindex
|
|
1276
|
+
*/
|
|
1277
|
+
arrindex: (...args: CommandArgs<typeof JsonArrIndexCommand>) =>
|
|
1278
|
+
this.chain(new JsonArrIndexCommand(args, this.commandOptions)),
|
|
1279
|
+
|
|
1280
|
+
/**
|
|
1281
|
+
* @see https://redis.io/commands/json.arrinsert
|
|
1282
|
+
*/
|
|
1283
|
+
arrinsert: (...args: CommandArgs<typeof JsonArrInsertCommand>) =>
|
|
1284
|
+
this.chain(new JsonArrInsertCommand(args, this.commandOptions)),
|
|
1285
|
+
|
|
1286
|
+
/**
|
|
1287
|
+
* @see https://redis.io/commands/json.arrlen
|
|
1288
|
+
*/
|
|
1289
|
+
arrlen: (...args: CommandArgs<typeof JsonArrLenCommand>) =>
|
|
1290
|
+
this.chain(new JsonArrLenCommand(args, this.commandOptions)),
|
|
1291
|
+
|
|
1292
|
+
/**
|
|
1293
|
+
* @see https://redis.io/commands/json.arrpop
|
|
1294
|
+
*/
|
|
1295
|
+
arrpop: (...args: CommandArgs<typeof JsonArrPopCommand>) =>
|
|
1296
|
+
this.chain(new JsonArrPopCommand(args, this.commandOptions)),
|
|
1297
|
+
|
|
1298
|
+
/**
|
|
1299
|
+
* @see https://redis.io/commands/json.arrtrim
|
|
1300
|
+
*/
|
|
1301
|
+
arrtrim: (...args: CommandArgs<typeof JsonArrTrimCommand>) =>
|
|
1302
|
+
this.chain(new JsonArrTrimCommand(args, this.commandOptions)),
|
|
1303
|
+
|
|
1304
|
+
/**
|
|
1305
|
+
* @see https://redis.io/commands/json.clear
|
|
1306
|
+
*/
|
|
1307
|
+
clear: (...args: CommandArgs<typeof JsonClearCommand>) =>
|
|
1308
|
+
this.chain(new JsonClearCommand(args, this.commandOptions)),
|
|
1309
|
+
|
|
1310
|
+
/**
|
|
1311
|
+
* @see https://redis.io/commands/json.del
|
|
1312
|
+
*/
|
|
1313
|
+
del: (...args: CommandArgs<typeof JsonDelCommand>) =>
|
|
1314
|
+
this.chain(new JsonDelCommand(args, this.commandOptions)),
|
|
1315
|
+
|
|
1316
|
+
/**
|
|
1317
|
+
* @see https://redis.io/commands/json.forget
|
|
1318
|
+
*/
|
|
1319
|
+
forget: (...args: CommandArgs<typeof JsonForgetCommand>) =>
|
|
1320
|
+
this.chain(new JsonForgetCommand(args, this.commandOptions)),
|
|
1321
|
+
|
|
1322
|
+
/**
|
|
1323
|
+
* @see https://redis.io/commands/json.get
|
|
1324
|
+
*/
|
|
1325
|
+
get: (...args: CommandArgs<typeof JsonGetCommand>) =>
|
|
1326
|
+
this.chain(new JsonGetCommand(args, this.commandOptions)),
|
|
1327
|
+
|
|
1328
|
+
/**
|
|
1329
|
+
* @see https://redis.io/commands/json.mget
|
|
1330
|
+
*/
|
|
1331
|
+
mget: (...args: CommandArgs<typeof JsonMGetCommand>) =>
|
|
1332
|
+
this.chain(new JsonMGetCommand(args, this.commandOptions)),
|
|
1333
|
+
|
|
1334
|
+
/**
|
|
1335
|
+
* @see https://redis.io/commands/json.mset
|
|
1336
|
+
*/
|
|
1337
|
+
mset: (...args: CommandArgs<typeof JsonMSetCommand>) =>
|
|
1338
|
+
this.chain(new JsonMSetCommand(args, this.commandOptions)),
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* @see https://redis.io/commands/json.numincrby
|
|
1342
|
+
*/
|
|
1343
|
+
numincrby: (...args: CommandArgs<typeof JsonNumIncrByCommand>) =>
|
|
1344
|
+
this.chain(new JsonNumIncrByCommand(args, this.commandOptions)),
|
|
1345
|
+
|
|
1346
|
+
/**
|
|
1347
|
+
* @see https://redis.io/commands/json.nummultby
|
|
1348
|
+
*/
|
|
1349
|
+
nummultby: (...args: CommandArgs<typeof JsonNumMultByCommand>) =>
|
|
1350
|
+
this.chain(new JsonNumMultByCommand(args, this.commandOptions)),
|
|
1351
|
+
|
|
1352
|
+
/**
|
|
1353
|
+
* @see https://redis.io/commands/json.objkeys
|
|
1354
|
+
*/
|
|
1355
|
+
objkeys: (...args: CommandArgs<typeof JsonObjKeysCommand>) =>
|
|
1356
|
+
this.chain(new JsonObjKeysCommand(args, this.commandOptions)),
|
|
1357
|
+
|
|
1358
|
+
/**
|
|
1359
|
+
* @see https://redis.io/commands/json.objlen
|
|
1360
|
+
*/
|
|
1361
|
+
objlen: (...args: CommandArgs<typeof JsonObjLenCommand>) =>
|
|
1362
|
+
this.chain(new JsonObjLenCommand(args, this.commandOptions)),
|
|
1363
|
+
|
|
1364
|
+
/**
|
|
1365
|
+
* @see https://redis.io/commands/json.resp
|
|
1366
|
+
*/
|
|
1367
|
+
resp: (...args: CommandArgs<typeof JsonRespCommand>) =>
|
|
1368
|
+
this.chain(new JsonRespCommand(args, this.commandOptions)),
|
|
1369
|
+
|
|
1370
|
+
/**
|
|
1371
|
+
* @see https://redis.io/commands/json.set
|
|
1372
|
+
*/
|
|
1373
|
+
set: (...args: CommandArgs<typeof JsonSetCommand>) =>
|
|
1374
|
+
this.chain(new JsonSetCommand(args, this.commandOptions)),
|
|
1375
|
+
|
|
1376
|
+
/**
|
|
1377
|
+
* @see https://redis.io/commands/json.strappend
|
|
1378
|
+
*/
|
|
1379
|
+
strappend: (...args: CommandArgs<typeof JsonStrAppendCommand>) =>
|
|
1380
|
+
this.chain(new JsonStrAppendCommand(args, this.commandOptions)),
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* @see https://redis.io/commands/json.strlen
|
|
1384
|
+
*/
|
|
1385
|
+
strlen: (...args: CommandArgs<typeof JsonStrLenCommand>) =>
|
|
1386
|
+
this.chain(new JsonStrLenCommand(args, this.commandOptions)),
|
|
1387
|
+
|
|
1388
|
+
/**
|
|
1389
|
+
* @see https://redis.io/commands/json.toggle
|
|
1390
|
+
*/
|
|
1391
|
+
toggle: (...args: CommandArgs<typeof JsonToggleCommand>) =>
|
|
1392
|
+
this.chain(new JsonToggleCommand(args, this.commandOptions)),
|
|
1393
|
+
|
|
1394
|
+
/**
|
|
1395
|
+
* @see https://redis.io/commands/json.type
|
|
1396
|
+
*/
|
|
1397
|
+
type: (...args: CommandArgs<typeof JsonTypeCommand>) =>
|
|
1398
|
+
this.chain(new JsonTypeCommand(args, this.commandOptions)),
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
}
|