discorcache 0.6.7__tar.gz
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.
- discorcache-0.6.7/.github/workflows/build-wheels.yml +103 -0
- discorcache-0.6.7/.gitignore +56 -0
- discorcache-0.6.7/Cargo.lock +326 -0
- discorcache-0.6.7/Cargo.toml +16 -0
- discorcache-0.6.7/PKG-INFO +9 -0
- discorcache-0.6.7/README.md +59 -0
- discorcache-0.6.7/pyproject.toml +27 -0
- discorcache-0.6.7/python/discorcache/__init__.py +354 -0
- discorcache-0.6.7/src/lib.rs +652 -0
- discorcache-0.6.7/uv.lock +1113 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
name: Build Wheels
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ['v*']
|
|
6
|
+
workflow_dispatch: # Manual trigger from GitHub UI
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
name: Build ${{ matrix.target }} (${{ matrix.os }})
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
include:
|
|
15
|
+
# Linux x86_64 (glibc)
|
|
16
|
+
- os: ubuntu-latest
|
|
17
|
+
target: x86_64-unknown-linux-gnu
|
|
18
|
+
manylinux: auto
|
|
19
|
+
# Linux x86_64 (musl - Alpine)
|
|
20
|
+
- os: ubuntu-latest
|
|
21
|
+
target: x86_64-unknown-linux-musl
|
|
22
|
+
manylinux: musllinux_1_2
|
|
23
|
+
# Linux i686 (32-bit glibc)
|
|
24
|
+
- os: ubuntu-latest
|
|
25
|
+
target: i686-unknown-linux-gnu
|
|
26
|
+
manylinux: auto
|
|
27
|
+
# Linux aarch64 (ARM64 glibc)
|
|
28
|
+
- os: ubuntu-latest
|
|
29
|
+
target: aarch64-unknown-linux-gnu
|
|
30
|
+
use_qemu: true
|
|
31
|
+
manylinux: manylinux_2_28
|
|
32
|
+
# Linux aarch64 (ARM64 musl - Alpine)
|
|
33
|
+
- os: ubuntu-latest
|
|
34
|
+
target: aarch64-unknown-linux-musl
|
|
35
|
+
use_qemu: true
|
|
36
|
+
manylinux: musllinux_1_2
|
|
37
|
+
# Windows x64
|
|
38
|
+
- os: windows-latest
|
|
39
|
+
target: x86_64-pc-windows-msvc
|
|
40
|
+
manylinux: auto
|
|
41
|
+
# macOS x86_64 (Intel)
|
|
42
|
+
- os: macos-14
|
|
43
|
+
target: x86_64-apple-darwin
|
|
44
|
+
manylinux: auto
|
|
45
|
+
# macOS aarch64 (Apple Silicon)
|
|
46
|
+
- os: macos-latest
|
|
47
|
+
target: aarch64-apple-darwin
|
|
48
|
+
manylinux: auto
|
|
49
|
+
# macOS Universal2 (Fat binaries)
|
|
50
|
+
- os: macos-latest
|
|
51
|
+
target: universal2-apple-darwin
|
|
52
|
+
manylinux: auto
|
|
53
|
+
|
|
54
|
+
runs-on: ${{ matrix.os }}
|
|
55
|
+
steps:
|
|
56
|
+
- uses: actions/checkout@v4
|
|
57
|
+
|
|
58
|
+
- name: Set up QEMU (for aarch64)
|
|
59
|
+
if: matrix.use_qemu
|
|
60
|
+
uses: docker/setup-qemu-action@v3
|
|
61
|
+
with:
|
|
62
|
+
platforms: arm64
|
|
63
|
+
|
|
64
|
+
- uses: actions/setup-python@v5
|
|
65
|
+
with:
|
|
66
|
+
python-version: |
|
|
67
|
+
3.10
|
|
68
|
+
3.11
|
|
69
|
+
3.12
|
|
70
|
+
3.13
|
|
71
|
+
|
|
72
|
+
- name: Build wheels
|
|
73
|
+
uses: PyO3/maturin-action@v1
|
|
74
|
+
with:
|
|
75
|
+
target: ${{ matrix.target }}
|
|
76
|
+
args: --release --out dist --interpreter 3.10 3.11 3.12 3.13
|
|
77
|
+
manylinux: ${{ matrix.manylinux }}
|
|
78
|
+
|
|
79
|
+
- name: Upload wheels
|
|
80
|
+
uses: actions/upload-artifact@v4
|
|
81
|
+
with:
|
|
82
|
+
name: wheels-${{ matrix.target }}
|
|
83
|
+
path: dist/*.whl
|
|
84
|
+
|
|
85
|
+
# Combine all wheels into one download
|
|
86
|
+
collect:
|
|
87
|
+
name: Collect all wheels
|
|
88
|
+
needs: build
|
|
89
|
+
runs-on: ubuntu-latest
|
|
90
|
+
steps:
|
|
91
|
+
- uses: actions/download-artifact@v4
|
|
92
|
+
with:
|
|
93
|
+
path: dist
|
|
94
|
+
pattern: wheels-*
|
|
95
|
+
merge-multiple: true
|
|
96
|
+
|
|
97
|
+
- name: List wheels
|
|
98
|
+
run: ls -lh dist/
|
|
99
|
+
|
|
100
|
+
- uses: actions/upload-artifact@v4
|
|
101
|
+
with:
|
|
102
|
+
name: all-wheels
|
|
103
|
+
path: dist/*.whl
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# ========== Rust / Cargo ==========
|
|
2
|
+
target/
|
|
3
|
+
**/target/
|
|
4
|
+
**/*.rs.bk
|
|
5
|
+
Cargo.lock
|
|
6
|
+
|
|
7
|
+
# Maturin / Python wheel builds
|
|
8
|
+
*.whl
|
|
9
|
+
*.egg-info/
|
|
10
|
+
build/
|
|
11
|
+
dist/
|
|
12
|
+
pip-wheel-metadata/
|
|
13
|
+
*.pyc
|
|
14
|
+
|
|
15
|
+
# ========== Python ==========
|
|
16
|
+
__pycache__/
|
|
17
|
+
*.py[cod]
|
|
18
|
+
*.pyo
|
|
19
|
+
*.pyd
|
|
20
|
+
.python-version
|
|
21
|
+
env/
|
|
22
|
+
venv/
|
|
23
|
+
ENV/
|
|
24
|
+
env.bak/
|
|
25
|
+
venv.bak/
|
|
26
|
+
|
|
27
|
+
# Poetry / pipenv / virtualenv
|
|
28
|
+
.poetry/
|
|
29
|
+
.mypy_cache/
|
|
30
|
+
.pytest_cache/
|
|
31
|
+
.coverage
|
|
32
|
+
.coverage.*
|
|
33
|
+
htmlcov/
|
|
34
|
+
.tox/
|
|
35
|
+
.nox/
|
|
36
|
+
|
|
37
|
+
# ========== IDEs / Editors ==========
|
|
38
|
+
.vscode/
|
|
39
|
+
.idea/
|
|
40
|
+
*.sublime-workspace
|
|
41
|
+
*.sublime-project
|
|
42
|
+
|
|
43
|
+
# ========== OS / Misc ==========
|
|
44
|
+
.DS_Store
|
|
45
|
+
Thumbs.db
|
|
46
|
+
desktop.ini
|
|
47
|
+
|
|
48
|
+
# ========== Build artifacts ==========
|
|
49
|
+
*.o
|
|
50
|
+
*.obj
|
|
51
|
+
*.so
|
|
52
|
+
*.dylib
|
|
53
|
+
*.dll
|
|
54
|
+
|
|
55
|
+
# ========== Logs ==========
|
|
56
|
+
*.log
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "autocfg"
|
|
7
|
+
version = "1.5.0"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "bitflags"
|
|
13
|
+
version = "2.11.0"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "cfg-if"
|
|
19
|
+
version = "1.0.4"
|
|
20
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
21
|
+
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "crossbeam-utils"
|
|
25
|
+
version = "0.8.21"
|
|
26
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
+
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
|
28
|
+
|
|
29
|
+
[[package]]
|
|
30
|
+
name = "dashmap"
|
|
31
|
+
version = "6.1.0"
|
|
32
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
33
|
+
checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf"
|
|
34
|
+
dependencies = [
|
|
35
|
+
"cfg-if",
|
|
36
|
+
"crossbeam-utils",
|
|
37
|
+
"hashbrown",
|
|
38
|
+
"lock_api",
|
|
39
|
+
"once_cell",
|
|
40
|
+
"parking_lot_core",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[[package]]
|
|
44
|
+
name = "discorcache"
|
|
45
|
+
version = "0.6.7"
|
|
46
|
+
dependencies = [
|
|
47
|
+
"dashmap",
|
|
48
|
+
"once_cell",
|
|
49
|
+
"pyo3",
|
|
50
|
+
"serde",
|
|
51
|
+
"serde_json",
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
[[package]]
|
|
55
|
+
name = "hashbrown"
|
|
56
|
+
version = "0.14.5"
|
|
57
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
58
|
+
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
|
59
|
+
|
|
60
|
+
[[package]]
|
|
61
|
+
name = "heck"
|
|
62
|
+
version = "0.5.0"
|
|
63
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
64
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
65
|
+
|
|
66
|
+
[[package]]
|
|
67
|
+
name = "indoc"
|
|
68
|
+
version = "2.0.7"
|
|
69
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
70
|
+
checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
|
|
71
|
+
dependencies = [
|
|
72
|
+
"rustversion",
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
[[package]]
|
|
76
|
+
name = "itoa"
|
|
77
|
+
version = "1.0.17"
|
|
78
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
79
|
+
checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2"
|
|
80
|
+
|
|
81
|
+
[[package]]
|
|
82
|
+
name = "libc"
|
|
83
|
+
version = "0.2.183"
|
|
84
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
85
|
+
checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
|
|
86
|
+
|
|
87
|
+
[[package]]
|
|
88
|
+
name = "lock_api"
|
|
89
|
+
version = "0.4.14"
|
|
90
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
91
|
+
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
|
|
92
|
+
dependencies = [
|
|
93
|
+
"scopeguard",
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
[[package]]
|
|
97
|
+
name = "memchr"
|
|
98
|
+
version = "2.8.0"
|
|
99
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
100
|
+
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
|
|
101
|
+
|
|
102
|
+
[[package]]
|
|
103
|
+
name = "memoffset"
|
|
104
|
+
version = "0.9.1"
|
|
105
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
106
|
+
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
107
|
+
dependencies = [
|
|
108
|
+
"autocfg",
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
[[package]]
|
|
112
|
+
name = "once_cell"
|
|
113
|
+
version = "1.21.4"
|
|
114
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
115
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
116
|
+
|
|
117
|
+
[[package]]
|
|
118
|
+
name = "parking_lot_core"
|
|
119
|
+
version = "0.9.12"
|
|
120
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
121
|
+
checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
|
|
122
|
+
dependencies = [
|
|
123
|
+
"cfg-if",
|
|
124
|
+
"libc",
|
|
125
|
+
"redox_syscall",
|
|
126
|
+
"smallvec",
|
|
127
|
+
"windows-link",
|
|
128
|
+
]
|
|
129
|
+
|
|
130
|
+
[[package]]
|
|
131
|
+
name = "portable-atomic"
|
|
132
|
+
version = "1.13.1"
|
|
133
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
134
|
+
checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
|
|
135
|
+
|
|
136
|
+
[[package]]
|
|
137
|
+
name = "proc-macro2"
|
|
138
|
+
version = "1.0.106"
|
|
139
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
140
|
+
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
|
141
|
+
dependencies = [
|
|
142
|
+
"unicode-ident",
|
|
143
|
+
]
|
|
144
|
+
|
|
145
|
+
[[package]]
|
|
146
|
+
name = "pyo3"
|
|
147
|
+
version = "0.23.5"
|
|
148
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
149
|
+
checksum = "7778bffd85cf38175ac1f545509665d0b9b92a198ca7941f131f85f7a4f9a872"
|
|
150
|
+
dependencies = [
|
|
151
|
+
"cfg-if",
|
|
152
|
+
"indoc",
|
|
153
|
+
"libc",
|
|
154
|
+
"memoffset",
|
|
155
|
+
"once_cell",
|
|
156
|
+
"portable-atomic",
|
|
157
|
+
"pyo3-build-config",
|
|
158
|
+
"pyo3-ffi",
|
|
159
|
+
"pyo3-macros",
|
|
160
|
+
"unindent",
|
|
161
|
+
]
|
|
162
|
+
|
|
163
|
+
[[package]]
|
|
164
|
+
name = "pyo3-build-config"
|
|
165
|
+
version = "0.23.5"
|
|
166
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
167
|
+
checksum = "94f6cbe86ef3bf18998d9df6e0f3fc1050a8c5efa409bf712e661a4366e010fb"
|
|
168
|
+
dependencies = [
|
|
169
|
+
"once_cell",
|
|
170
|
+
"target-lexicon",
|
|
171
|
+
]
|
|
172
|
+
|
|
173
|
+
[[package]]
|
|
174
|
+
name = "pyo3-ffi"
|
|
175
|
+
version = "0.23.5"
|
|
176
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
177
|
+
checksum = "e9f1b4c431c0bb1c8fb0a338709859eed0d030ff6daa34368d3b152a63dfdd8d"
|
|
178
|
+
dependencies = [
|
|
179
|
+
"libc",
|
|
180
|
+
"pyo3-build-config",
|
|
181
|
+
]
|
|
182
|
+
|
|
183
|
+
[[package]]
|
|
184
|
+
name = "pyo3-macros"
|
|
185
|
+
version = "0.23.5"
|
|
186
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
187
|
+
checksum = "fbc2201328f63c4710f68abdf653c89d8dbc2858b88c5d88b0ff38a75288a9da"
|
|
188
|
+
dependencies = [
|
|
189
|
+
"proc-macro2",
|
|
190
|
+
"pyo3-macros-backend",
|
|
191
|
+
"quote",
|
|
192
|
+
"syn",
|
|
193
|
+
]
|
|
194
|
+
|
|
195
|
+
[[package]]
|
|
196
|
+
name = "pyo3-macros-backend"
|
|
197
|
+
version = "0.23.5"
|
|
198
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
199
|
+
checksum = "fca6726ad0f3da9c9de093d6f116a93c1a38e417ed73bf138472cf4064f72028"
|
|
200
|
+
dependencies = [
|
|
201
|
+
"heck",
|
|
202
|
+
"proc-macro2",
|
|
203
|
+
"pyo3-build-config",
|
|
204
|
+
"quote",
|
|
205
|
+
"syn",
|
|
206
|
+
]
|
|
207
|
+
|
|
208
|
+
[[package]]
|
|
209
|
+
name = "quote"
|
|
210
|
+
version = "1.0.45"
|
|
211
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
212
|
+
checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
|
|
213
|
+
dependencies = [
|
|
214
|
+
"proc-macro2",
|
|
215
|
+
]
|
|
216
|
+
|
|
217
|
+
[[package]]
|
|
218
|
+
name = "redox_syscall"
|
|
219
|
+
version = "0.5.18"
|
|
220
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
221
|
+
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
|
|
222
|
+
dependencies = [
|
|
223
|
+
"bitflags",
|
|
224
|
+
]
|
|
225
|
+
|
|
226
|
+
[[package]]
|
|
227
|
+
name = "rustversion"
|
|
228
|
+
version = "1.0.22"
|
|
229
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
230
|
+
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
|
231
|
+
|
|
232
|
+
[[package]]
|
|
233
|
+
name = "scopeguard"
|
|
234
|
+
version = "1.2.0"
|
|
235
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
236
|
+
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
|
237
|
+
|
|
238
|
+
[[package]]
|
|
239
|
+
name = "serde"
|
|
240
|
+
version = "1.0.228"
|
|
241
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
242
|
+
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
|
243
|
+
dependencies = [
|
|
244
|
+
"serde_core",
|
|
245
|
+
"serde_derive",
|
|
246
|
+
]
|
|
247
|
+
|
|
248
|
+
[[package]]
|
|
249
|
+
name = "serde_core"
|
|
250
|
+
version = "1.0.228"
|
|
251
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
252
|
+
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
|
253
|
+
dependencies = [
|
|
254
|
+
"serde_derive",
|
|
255
|
+
]
|
|
256
|
+
|
|
257
|
+
[[package]]
|
|
258
|
+
name = "serde_derive"
|
|
259
|
+
version = "1.0.228"
|
|
260
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
261
|
+
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
|
262
|
+
dependencies = [
|
|
263
|
+
"proc-macro2",
|
|
264
|
+
"quote",
|
|
265
|
+
"syn",
|
|
266
|
+
]
|
|
267
|
+
|
|
268
|
+
[[package]]
|
|
269
|
+
name = "serde_json"
|
|
270
|
+
version = "1.0.149"
|
|
271
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
272
|
+
checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86"
|
|
273
|
+
dependencies = [
|
|
274
|
+
"itoa",
|
|
275
|
+
"memchr",
|
|
276
|
+
"serde",
|
|
277
|
+
"serde_core",
|
|
278
|
+
"zmij",
|
|
279
|
+
]
|
|
280
|
+
|
|
281
|
+
[[package]]
|
|
282
|
+
name = "smallvec"
|
|
283
|
+
version = "1.15.1"
|
|
284
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
285
|
+
checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
|
286
|
+
|
|
287
|
+
[[package]]
|
|
288
|
+
name = "syn"
|
|
289
|
+
version = "2.0.117"
|
|
290
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
291
|
+
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
|
|
292
|
+
dependencies = [
|
|
293
|
+
"proc-macro2",
|
|
294
|
+
"quote",
|
|
295
|
+
"unicode-ident",
|
|
296
|
+
]
|
|
297
|
+
|
|
298
|
+
[[package]]
|
|
299
|
+
name = "target-lexicon"
|
|
300
|
+
version = "0.12.16"
|
|
301
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
302
|
+
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
|
303
|
+
|
|
304
|
+
[[package]]
|
|
305
|
+
name = "unicode-ident"
|
|
306
|
+
version = "1.0.24"
|
|
307
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
308
|
+
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
|
309
|
+
|
|
310
|
+
[[package]]
|
|
311
|
+
name = "unindent"
|
|
312
|
+
version = "0.2.4"
|
|
313
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
314
|
+
checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
|
|
315
|
+
|
|
316
|
+
[[package]]
|
|
317
|
+
name = "windows-link"
|
|
318
|
+
version = "0.2.1"
|
|
319
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
320
|
+
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
|
321
|
+
|
|
322
|
+
[[package]]
|
|
323
|
+
name = "zmij"
|
|
324
|
+
version = "1.0.21"
|
|
325
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
326
|
+
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "discorcache"
|
|
3
|
+
version = "0.6.7"
|
|
4
|
+
edition = "2024"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
|
|
7
|
+
[lib]
|
|
8
|
+
name = "discorcache"
|
|
9
|
+
crate-type = ["cdylib"]
|
|
10
|
+
|
|
11
|
+
[dependencies]
|
|
12
|
+
pyo3 = { version = "0.23", features = ["extension-module", "abi3-py39"] }
|
|
13
|
+
dashmap = "6.1"
|
|
14
|
+
once_cell = "1.20"
|
|
15
|
+
serde = { version = "1.0", features = ["derive"] }
|
|
16
|
+
serde_json = "1.0"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: discorcache
|
|
3
|
+
Version: 0.6.7
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
7
|
+
Requires-Dist: discord-py>=2.0
|
|
8
|
+
Requires-Dist: psutil>=5.9
|
|
9
|
+
Requires-Python: >=3.9
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# discorcache
|
|
2
|
+
A Rust-backed transparent caching layer for `discord.py` objects.
|
|
3
|
+
|
|
4
|
+
`discorcache` intercepts the creation of discord objects (Guilds, Users, Members, Roles, Messages), moves their data off the Python heap and into a high-performance multithreaded Rust `DashMap`. It replaces the standard `__dict__` and `__slots__` mechanisms with weak-references and C-extension lookups.
|
|
5
|
+
|
|
6
|
+
The result is a structurally compliant `discord.py` bot with dramatically lower memory consumption at scale.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
You will need `uv` and a Rust compiler.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
uv add msgspec attrs
|
|
14
|
+
uv pip install maturin
|
|
15
|
+
uv run maturin develop --release
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Using `discorcache` is intentionally zero-configuration. You just import it before running your bot.
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
import discord
|
|
24
|
+
from discord.ext import commands
|
|
25
|
+
|
|
26
|
+
# The moment you import discorcache, the patch is applied.
|
|
27
|
+
import discorcache
|
|
28
|
+
|
|
29
|
+
TOKEN = "YOUR_BOT_TOKEN_HERE"
|
|
30
|
+
intents = discord.Intents.all()
|
|
31
|
+
|
|
32
|
+
# To maximize RAM savings, turn off discord.py's internal Python caches
|
|
33
|
+
# so that ONLY the Rust registry holds the persistent state.
|
|
34
|
+
bot = commands.Bot(
|
|
35
|
+
command_prefix="!",
|
|
36
|
+
intents=intents,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
@bot.event
|
|
40
|
+
async def on_ready():
|
|
41
|
+
print(f"Logged in as {bot.user}")
|
|
42
|
+
|
|
43
|
+
@bot.command()
|
|
44
|
+
async def userinfo(ctx, member: discord.Member = None):
|
|
45
|
+
# This member object looks and behaves normally, but its properties
|
|
46
|
+
# (e.g. `m.name`, `m.joined_at`) are being pulled seamlessly from Rust.
|
|
47
|
+
m = member or ctx.author
|
|
48
|
+
await ctx.send(f"Name: {m.name}, Joined: {m.joined_at}")
|
|
49
|
+
|
|
50
|
+
bot.run(TOKEN)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## How It Works
|
|
54
|
+
|
|
55
|
+
1. Module import executes `patch_discord_classes()`.
|
|
56
|
+
2. Core init routines for `discord.User`, `discord.Member`, `discord.Guild`, `discord.Role`, and `discord.Message` are monkeypatched.
|
|
57
|
+
3. Every time Discord triggers a `GUILD_CREATE` or `MESSAGE_CREATE` event, the initialised payload is immediately serialized over Rust ABI into `dashmap`.
|
|
58
|
+
4. The Python object's heavy properties are dropped and replaced securely behind an overridden `__getattr__` that reads backwards directly from Rust memory space when queried locally by your bot.
|
|
59
|
+
5. Large collections like `ConnectionState._users` are substituted with `WeakValueDictionary`, allowing python to aggressively garbage collect references it is no longer actively manipulating.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["maturin>=1.0,<2.0"]
|
|
3
|
+
build-backend = "maturin"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "discorcache"
|
|
7
|
+
version = "0.6.7"
|
|
8
|
+
requires-python = ">=3.9"
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Programming Language :: Rust",
|
|
11
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
12
|
+
"Programming Language :: Python :: Implementation :: PyPy",
|
|
13
|
+
]
|
|
14
|
+
dependencies = [
|
|
15
|
+
"discord.py>=2.0",
|
|
16
|
+
"psutil>=5.9",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[tool.maturin]
|
|
20
|
+
features = ["pyo3/extension-module"]
|
|
21
|
+
module-name = "discorcache.discorcache"
|
|
22
|
+
python-source = "python"
|
|
23
|
+
|
|
24
|
+
[dependency-groups]
|
|
25
|
+
dev = [
|
|
26
|
+
"maturin>=1.12.6",
|
|
27
|
+
]
|