Skip to content

Commit

Permalink
feat!: bump dependencies, create RedisInstance class
Browse files Browse the repository at this point in the history
  • Loading branch information
kane50613 committed Oct 16, 2024
1 parent 581e14c commit 1584265
Show file tree
Hide file tree
Showing 15 changed files with 1,779 additions and 1,410 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
version: 9
run_install: false

- name: Get pnpm store directory
Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ This is the minimal example to connect to a Redis server.
```ts
import { createRedis } from "redis-on-workers";

const redis = createRedis({
url: "redis://<username>:<password>@<host>:<port>",
});
const redis = createRedis("redis://<username>:<password>@<host>:<port>");

await redis("SET", "foo", "bar");
await redis.send("SET", "foo", "bar");

const value = await redis("GET", "foo");
const value = await redis.send("GET", "foo");

console.log(value); // bar

// remember to close the connection after use, or use `redis.sendOnce`.
await redis.close();
```

### Raw Uint8Array
Expand All @@ -37,13 +38,11 @@ This is useful if you want to store binary data. For example, you can store prot
```ts
import { createRedis } from "redis-on-workers";

const redis = createRedis({
url: "redis://<username>:<password>@<host>:<port>",
});
const redis = createRedis( "redis://<username>:<password>@<host>:<port>");

await redis.raw("SET", "foo", "bar");
await redis.sendRaw("SET", "foo", "bar");

const value = await redis.raw("GET", "foo");
const value = await redis.sendRawOnce("GET", "foo");

const decoder = new TextDecoder();

Expand All @@ -60,10 +59,12 @@ npm install @arrowood.dev/socket

## API

### `createRedis(options: RedisOptions): Redis`
### `createRedis(options: CreateRedisOptions | string): RedisInstance`

Create a new Redis client, does NOT connect to the server yet, the connection will be established when the first command is sent.

Or you can start connection immediately by using `redis.startConnection()`.

### `RedisOptions`

- `url` (string): The URL of the Redis server.
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@
"type": "module",
"license": "MIT",
"devDependencies": {
"@cloudflare/workers-types": "^4.20240222.0",
"@types/node": "^20.11.24",
"prettier": "^3.2.5",
"prettier-plugin-organize-imports": "^3.2.4",
"tsup": "^8.0.2",
"tsx": "^4.7.1",
"typescript": "^5.3.3",
"vitest": "^1.3.1"
"@cloudflare/workers-types": "^4.20241011.0",
"@types/node": "^22.7.5",
"prettier": "^3.3.3",
"prettier-plugin-organize-imports": "^4.1.0",
"tsup": "^8.3.0",
"tsx": "^4.19.1",
"typescript": "^5.6.3",
"vitest": "^2.1.3"
},
"optionalDependencies": {
"@arrowood.dev/socket": "^0.2.0"
Expand Down
Loading

0 comments on commit 1584265

Please sign in to comment.