Skip to content

DX-438: Add command docs for upstash-redis python package #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 50 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
8ce2e67
Copy @upstash/redis docs to python
ytkimirti Nov 3, 2023
1b06463
simple initial regex edit
ytkimirti Nov 3, 2023
a074974
another regex edit
ytkimirti Nov 3, 2023
b9334ef
doc
ytkimirti Nov 3, 2023
5782745
Change the overview links
ytkimirti Nov 3, 2023
dcb19ae
doc
ytkimirti Nov 3, 2023
4866db2
Remove all awaits, use sync examples
ytkimirti Nov 3, 2023
15933b3
doc
ytkimirti Nov 3, 2023
c1ead27
Change type to str from string
ytkimirti Nov 6, 2023
0269996
Expire docs
ytkimirti Nov 7, 2023
7183234
doc
ytkimirti Nov 7, 2023
3c386b3
Fix small typo in link
ytkimirti Nov 7, 2023
0c67a92
replace type="integer" to type="int"
ytkimirti Nov 7, 2023
b5a671f
doc bitcount
ytkimirti Nov 7, 2023
e285178
Remove the DUMP and RESTORE docs since they are not implemented yet
ytkimirti Nov 7, 2023
7cf7823
Regex change types
ytkimirti Nov 8, 2023
2051d4a
Remove SORT docs, since command does not exist
ytkimirti Nov 8, 2023
bd89102
doc
ytkimirti Nov 8, 2023
e7e39a7
Add hmset command
ytkimirti Nov 8, 2023
bfa8cb2
doc
ytkimirti Nov 8, 2023
384e426
doc
ytkimirti Nov 8, 2023
bdfbc39
Remove JSON commands from python docs
ytkimirti Nov 8, 2023
b4dc181
remove non supported pages
ytkimirti Nov 8, 2023
b1a6bef
doc
ytkimirti Nov 8, 2023
5068c7e
Fix link
ytkimirti Nov 8, 2023
cc47301
fix typo
ytkimirti Nov 8, 2023
e74cebf
doc
ytkimirti Nov 8, 2023
97ef099
doc
ytkimirti Nov 14, 2023
b26d297
doc
ytkimirti Nov 14, 2023
33d7142
fix typescript mistakes
ytkimirti Nov 14, 2023
0853e03
doc
ytkimirti Nov 14, 2023
e9d7448
doc
ytkimirti Nov 15, 2023
0d15550
fix SADD return description
ytkimirti Nov 15, 2023
8eccfb2
doc
ytkimirti Nov 15, 2023
67e5be1
improve scan docs
ytkimirti Nov 15, 2023
3081d09
doc
ytkimirti Nov 15, 2023
d53633a
remove stream command docs from py
ytkimirti Nov 15, 2023
b3ca86e
doc
ytkimirti Nov 15, 2023
b24d352
fix small typos
ytkimirti Nov 15, 2023
abf0a34
doc
ytkimirti Nov 18, 2023
4a16d50
fix bitop description
ytkimirti Nov 18, 2023
23eab4f
Add bitfield command doc
ytkimirti Nov 18, 2023
9ee4132
doc
ytkimirti Nov 18, 2023
b4ecfd9
Add diff inter and union commands
ytkimirti Nov 18, 2023
34c30c7
doc
ytkimirti Nov 18, 2023
3607704
doc
ytkimirti Nov 18, 2023
4b14e43
add zrandmember
ytkimirti Nov 18, 2023
88817de
doc
ytkimirti Nov 18, 2023
d487c69
fix mistake in mint file
ytkimirti Nov 20, 2023
a28a679
Remove old reference to transaction file in mint file
ytkimirti Nov 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 182 additions & 3 deletions mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,7 @@
"oss/sdks/ts/redis/commands/generic/randomkey",
"oss/sdks/ts/redis/commands/generic/rename",
"oss/sdks/ts/redis/commands/generic/renamenx",
"oss/sdks/ts/redis/commands/generic/restore",
"oss/sdks/ts/redis/commands/generic/scan",
"oss/sdks/ts/redis/commands/generic/sort",
"oss/sdks/ts/redis/commands/generic/touch",
"oss/sdks/ts/redis/commands/generic/ttl",
"oss/sdks/ts/redis/commands/generic/type",
Expand Down Expand Up @@ -818,7 +816,188 @@
"pages": [
"oss/sdks/py/redis/overview",
"oss/sdks/py/redis/gettingstarted",
"oss/sdks/py/redis/features"
"oss/sdks/py/redis/features",

{
"group": "Commands",
"pages": [
"oss/sdks/py/redis/commands/overview",

{
"group": "Auth",
"pages": [
"oss/sdks/py/redis/commands/auth/echo",
"oss/sdks/py/redis/commands/auth/ping"
]
},
{
"group": "Bitmap",
"pages": [
"oss/sdks/py/redis/commands/bitmap/bitcount",
"oss/sdks/py/redis/commands/bitmap/bitfield",
"oss/sdks/py/redis/commands/bitmap/bitop",
"oss/sdks/py/redis/commands/bitmap/bitpos",
"oss/sdks/py/redis/commands/bitmap/getbit"
]
},
{
"group": "Generic",
"pages": [
"oss/sdks/py/redis/commands/generic/del",
"oss/sdks/py/redis/commands/generic/exists",
"oss/sdks/py/redis/commands/generic/expire",
"oss/sdks/py/redis/commands/generic/expireat",
"oss/sdks/py/redis/commands/generic/keys",
"oss/sdks/py/redis/commands/generic/persist",
"oss/sdks/py/redis/commands/generic/pexpire",
"oss/sdks/py/redis/commands/generic/pexpireat",
"oss/sdks/py/redis/commands/generic/pttl",
"oss/sdks/py/redis/commands/generic/randomkey",
"oss/sdks/py/redis/commands/generic/rename",
"oss/sdks/py/redis/commands/generic/renamenx",
"oss/sdks/py/redis/commands/generic/scan",
"oss/sdks/py/redis/commands/generic/touch",
"oss/sdks/py/redis/commands/generic/ttl",
"oss/sdks/py/redis/commands/generic/type",
"oss/sdks/py/redis/commands/generic/unlink"
]
},

{
"group": "Hash",
"pages": [
"oss/sdks/py/redis/commands/hash/hdel",
"oss/sdks/py/redis/commands/hash/hexists",
"oss/sdks/py/redis/commands/hash/hget",
"oss/sdks/py/redis/commands/hash/hgetall",
"oss/sdks/py/redis/commands/hash/hincrby",
"oss/sdks/py/redis/commands/hash/hincrbyfloat",
"oss/sdks/py/redis/commands/hash/hkeys",
"oss/sdks/py/redis/commands/hash/hlen",
"oss/sdks/py/redis/commands/hash/hmget",
"oss/sdks/py/redis/commands/hash/hrandfield",
"oss/sdks/py/redis/commands/hash/hscan",
"oss/sdks/py/redis/commands/hash/hset",
"oss/sdks/py/redis/commands/hash/hmset",
"oss/sdks/py/redis/commands/hash/hsetnx",
"oss/sdks/py/redis/commands/hash/hstrlen",
"oss/sdks/py/redis/commands/hash/hvals"
]
},
{
"group": "List",
"pages": [
"oss/sdks/py/redis/commands/list/lindex",
"oss/sdks/py/redis/commands/list/linsert",
"oss/sdks/py/redis/commands/list/llen",
"oss/sdks/py/redis/commands/list/lmove",
"oss/sdks/py/redis/commands/list/lpop",
"oss/sdks/py/redis/commands/list/lpos",
"oss/sdks/py/redis/commands/list/lpush",
"oss/sdks/py/redis/commands/list/lpushx",
"oss/sdks/py/redis/commands/list/lrange",
"oss/sdks/py/redis/commands/list/lrem",
"oss/sdks/py/redis/commands/list/lset",
"oss/sdks/py/redis/commands/list/ltrim",
"oss/sdks/py/redis/commands/list/rpop",
"oss/sdks/py/redis/commands/list/rpush",
"oss/sdks/py/redis/commands/list/rpushx"
]
},
{
"group": "PubSub",
"pages": ["oss/sdks/py/redis/commands/pubsub/publish"]
},
{
"group": "Scripts",
"pages": [
"oss/sdks/py/redis/commands/scripts/eval",
"oss/sdks/py/redis/commands/scripts/evalsha",
"oss/sdks/py/redis/commands/scripts/script_exists",
"oss/sdks/py/redis/commands/scripts/script_flush",
"oss/sdks/py/redis/commands/scripts/script_load"
]
},
{
"group": "Server",
"pages": [
"oss/sdks/py/redis/commands/server/dbsize",
"oss/sdks/py/redis/commands/server/flushall",
"oss/sdks/py/redis/commands/server/flushdb"
]
},
{
"group": "Set",
"pages": [
"oss/sdks/py/redis/commands/set/sadd",
"oss/sdks/py/redis/commands/set/scard",
"oss/sdks/py/redis/commands/set/sdiff",
"oss/sdks/py/redis/commands/set/sdiffstore",
"oss/sdks/py/redis/commands/set/sinter",
"oss/sdks/py/redis/commands/set/sinterstore",
"oss/sdks/py/redis/commands/set/sismember",
"oss/sdks/py/redis/commands/set/smembers",
"oss/sdks/py/redis/commands/set/smismember",
"oss/sdks/py/redis/commands/set/smove",
"oss/sdks/py/redis/commands/set/spop",
"oss/sdks/py/redis/commands/set/srandmember",
"oss/sdks/py/redis/commands/set/srem",
"oss/sdks/py/redis/commands/set/sscan",
"oss/sdks/py/redis/commands/set/sunion",
"oss/sdks/py/redis/commands/set/sunionstore"
]
},
{
"group": "Sorted Set",
"pages": [
"oss/sdks/py/redis/commands/zset/zadd",
"oss/sdks/py/redis/commands/zset/zcard",
"oss/sdks/py/redis/commands/zset/zcount",
"oss/sdks/py/redis/commands/zset/zdiff",
"oss/sdks/py/redis/commands/zset/zdiffstore",
"oss/sdks/py/redis/commands/zset/zincrby",
"oss/sdks/py/redis/commands/zset/zinter",
"oss/sdks/py/redis/commands/zset/zinterstore",
"oss/sdks/py/redis/commands/zset/zlexcount",
"oss/sdks/py/redis/commands/zset/zmscore",
"oss/sdks/py/redis/commands/zset/zpopmax",
"oss/sdks/py/redis/commands/zset/zpopmin",
"oss/sdks/py/redis/commands/zset/zrandmember",
"oss/sdks/py/redis/commands/zset/zrange",
"oss/sdks/py/redis/commands/zset/zrank",
"oss/sdks/py/redis/commands/zset/zrem",
"oss/sdks/py/redis/commands/zset/zremrangebylex",
"oss/sdks/py/redis/commands/zset/zremrangebyrank",
"oss/sdks/py/redis/commands/zset/zremrangebyscore",
"oss/sdks/py/redis/commands/zset/zrevrank",
"oss/sdks/py/redis/commands/zset/zscan",
"oss/sdks/py/redis/commands/zset/zscore",
"oss/sdks/py/redis/commands/zset/zunion",
"oss/sdks/py/redis/commands/zset/zunionstore"
]
},
{
"group": "String",
"pages": [
"oss/sdks/py/redis/commands/string/append",
"oss/sdks/py/redis/commands/string/decr",
"oss/sdks/py/redis/commands/string/decrby",
"oss/sdks/py/redis/commands/string/get",
"oss/sdks/py/redis/commands/string/getrange",
"oss/sdks/py/redis/commands/string/getset",
"oss/sdks/py/redis/commands/string/incr",
"oss/sdks/py/redis/commands/string/incrby",
"oss/sdks/py/redis/commands/string/incrbyfloat",
"oss/sdks/py/redis/commands/string/mget",
"oss/sdks/py/redis/commands/string/mset",
"oss/sdks/py/redis/commands/string/msetnx",
"oss/sdks/py/redis/commands/string/set",
"oss/sdks/py/redis/commands/string/setrange",
"oss/sdks/py/redis/commands/string/strlen"
]
}
]
}
]
}
]
Expand Down
23 changes: 23 additions & 0 deletions oss/sdks/py/redis/commands/auth/echo.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: ECHO
---

Returns a message back to you. Useful for debugging the connection.

## Arguments

<ParamField body="message" type="str" required>
A message to send to the server.
</ParamField>

## Response

<ResponseField type="str" required>
The same message you sent.
</ResponseField>

<RequestExample>
```py Example
assert redis.echo("hello world") == "hello world"
```
</RequestExample>
20 changes: 20 additions & 0 deletions oss/sdks/py/redis/commands/auth/ping.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: PING
description: Send a ping to the server and get a response if the server is alive.
---

## Arguments

No arguments

## Response

<ResponseField type="str" required>
`PONG`
</ResponseField>

<RequestExample>
```py Example
assert redis.pong() == "PONG"
```
</RequestExample>
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,37 @@ The `BITCOUNT` command in Redis is used to count the number of set bits (bits wi

## Arguments

<ParamField body="key" type="string" required>
<ParamField body="key" type="str" required>
The key to get.
</ParamField>

<ParamField body="start" type="integer">
<ParamField body="start" type="int">
Specify the range of bytes within the binary string to count the set bits. If not provided, it counts set bits in the entire string.

Either specify both `start` and `end` or neither.

Either specify both `start` and `end` or neither.
</ParamField>

<ParamField body="end" type="integer">
<ParamField body="end" type="int">
Specify the range of bytes within the binary string to count the set bits. If not provided, it counts set bits in the entire string.

Either specify both `start` and `end` or neither.
</ParamField>
## Response

<ResponseField type="integer" required>
<ResponseField type="int" required>
The number of set bits in the specified range.
</ResponseField>

<RequestExample>
```ts Example
const bits = await redis.bitcount(key);
```
```ts With Range
const bits = await redis.bitcount(key, 5, 10);
```py Example
redis.setbit("mykey", 7, 1)
redis.setbit("mykey", 8, 1)
redis.setbit("mykey", 9, 1)

# With range
assert redis.bitcount("mykey", 0, 10) == 3

# Without range
assert redis.bitcount("mykey") == 3
```
</RequestExample>
90 changes: 90 additions & 0 deletions oss/sdks/py/redis/commands/bitmap/bitfield.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
title: BITFIELD
description: Sets or gets parts of a bitfield
---

The `bitfield` function returns a `BitFieldCommands` instance that can be used
to execute multiple bitfield operations in a single command.

The encoding can be a signed or unsigned integer, by prefixing the type with
`i` or `u`. For example, `i4` is a signed 4-bit integer, and `u8` is an
unsigned 8-bit integer.

```py
redis.set("mykey", "")

# Sets the first 4 bits to 1
# Increments the next 4 bits by 1
result = redis.bitfield("mykey")
.set("u4", 0, 16)
.incr("u4", 4, 1)
.execute()

assert result == [0, 1]
```

## Commands

### `get(type: str, offset: int)`

Returns a value from the bitfield at the given offset.

### `set(type: str, offset: int, value: int)`

Sets a value and returns the old value.

### `incr(type: str, offset: int, increment: int)`

Increments a value and returns the new value.

## Arguments

<ParamField body="key" type="str" required>
The string key to operate on.
</ParamField>

## Response

<ResponseField type="List[int]" required>
A list of integers, one for each operation.
</ResponseField>

<RequestExample>
```py Get
redis.set("mykey", "\x05\x06\x07")

result = redis.bitfield("mykey") \
.get("u8", 0) \
.get("u8", 8) \
.get("u8", 16) \
.execute()

assert result == [5, 6, 7]
```

```py Set
redis.set("mykey", "")

result = redis.bitfield("mykey") \
.set("u4", 0, 16) \
.set("u4", 4, 1) \
.execute()

assert result == [0, 1]
```

```py Incr
redis.set("mykey", "")

# Increment offset 0 by 16, return
# Increment offset 4 by 1

result = redis.bitfield("mykey") \
.incr("u4", 0, 16) \
.incr("u4", 4, 1) \
.execute()

assert result == [0, 1]
```

</RequestExample>
Loading