credish 0.0.2__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.
- credish-0.0.2/LICENSE +21 -0
- credish-0.0.2/MANIFEST.in +3 -0
- credish-0.0.2/PKG-INFO +216 -0
- credish-0.0.2/README.md +198 -0
- credish-0.0.2/credish/__init__.py +13 -0
- credish-0.0.2/credish/_credish.pyi +52 -0
- credish-0.0.2/credish/client.py +421 -0
- credish-0.0.2/credish/constants.py +19 -0
- credish-0.0.2/credish/exceptions.py +15 -0
- credish-0.0.2/credish.egg-info/PKG-INFO +216 -0
- credish-0.0.2/credish.egg-info/SOURCES.txt +43 -0
- credish-0.0.2/credish.egg-info/dependency_links.txt +1 -0
- credish-0.0.2/credish.egg-info/requires.txt +5 -0
- credish-0.0.2/credish.egg-info/top_level.txt +1 -0
- credish-0.0.2/pyproject.toml +43 -0
- credish-0.0.2/setup.cfg +4 -0
- credish-0.0.2/setup.py +36 -0
- credish-0.0.2/src/_credish/adlist.c +114 -0
- credish-0.0.2/src/_credish/adlist.h +30 -0
- credish-0.0.2/src/_credish/bufpool.c +122 -0
- credish-0.0.2/src/_credish/bufpool.h +26 -0
- credish-0.0.2/src/_credish/credish_module.c +1056 -0
- credish-0.0.2/src/_credish/db.c +241 -0
- credish-0.0.2/src/_credish/db.h +60 -0
- credish-0.0.2/src/_credish/dict.c +266 -0
- credish-0.0.2/src/_credish/dict.h +69 -0
- credish-0.0.2/src/_credish/expire.c +88 -0
- credish-0.0.2/src/_credish/expire.h +9 -0
- credish-0.0.2/src/_credish/intset.c +49 -0
- credish-0.0.2/src/_credish/intset.h +19 -0
- credish-0.0.2/src/_credish/object.c +158 -0
- credish-0.0.2/src/_credish/object.h +55 -0
- credish-0.0.2/src/_credish/persistence/aof.c +264 -0
- credish-0.0.2/src/_credish/persistence/aof.h +10 -0
- credish-0.0.2/src/_credish/persistence/rdb.c +431 -0
- credish-0.0.2/src/_credish/persistence/rdb.h +10 -0
- credish-0.0.2/src/_credish/platform.h +200 -0
- credish-0.0.2/src/_credish/sds.c +96 -0
- credish-0.0.2/src/_credish/sds.h +45 -0
- credish-0.0.2/src/_credish/server.c +17 -0
- credish-0.0.2/src/_credish/server.h +29 -0
- credish-0.0.2/src/_credish/skiplist.c +163 -0
- credish-0.0.2/src/_credish/skiplist.h +34 -0
- credish-0.0.2/src/_credish/sorted_set.c +537 -0
- credish-0.0.2/src/_credish/sorted_set.h +22 -0
credish-0.0.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ravisxcr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
credish-0.0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: credish
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: Redis-compatible in-process cache as a Python C extension
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/Ravisxcr/credish
|
|
7
|
+
Project-URL: Repository, https://github.com/Ravisxcr/credish
|
|
8
|
+
Project-URL: Documentation, https://github.com/Ravisxcr/credish/tree/main/docs
|
|
9
|
+
Project-URL: Issues, https://github.com/Ravisxcr/credish/issues
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Provides-Extra: dev
|
|
14
|
+
Requires-Dist: cibuildwheel; extra == "dev"
|
|
15
|
+
Requires-Dist: pytest; extra == "dev"
|
|
16
|
+
Requires-Dist: pytest-timeout; extra == "dev"
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# Credish
|
|
20
|
+
|
|
21
|
+
[](https://pypi.org/project/credish/)
|
|
22
|
+
[](https://pypi.org/project/credish/)
|
|
23
|
+
[](https://github.com/Ravisxcr/credish/blob/main/LICENSE)
|
|
24
|
+
|
|
25
|
+
Credish is a Redis-compatible, in-process cache for Python. It provides a
|
|
26
|
+
`redis-py`-style client backed by a native C extension, so applications can use
|
|
27
|
+
familiar Redis commands without running a separate Redis server process.
|
|
28
|
+
|
|
29
|
+
Credish is currently early-stage. The main supported areas are strings, lists,
|
|
30
|
+
sorted sets, key expiry, logical databases, and local persistence.
|
|
31
|
+
|
|
32
|
+
## Why Credish?
|
|
33
|
+
|
|
34
|
+
- In-process cache with no Redis server process to manage
|
|
35
|
+
- Native C storage engine exposed through a small Python API
|
|
36
|
+
- Redis-like commands for common strings, lists, sorted sets, keys, and expiry
|
|
37
|
+
- Logical database selection with indexes `0` through `15`
|
|
38
|
+
- Persistence modes for no persistence, RDB snapshots, AOF logs, or both
|
|
39
|
+
- Context-manager client support for clean native resource handling
|
|
40
|
+
- Python 3.10+ packaging with editable installs and wheel build support
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
Credish builds a C extension, so you need Python 3.10 or newer and a C
|
|
45
|
+
compiler. On Linux and macOS the compiler must support POSIX threads; on
|
|
46
|
+
Windows, native threading APIs are used instead.
|
|
47
|
+
|
|
48
|
+
Install from PyPI:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
python -m pip install credish
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
For local development, install the package in editable mode with development
|
|
55
|
+
dependencies:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
cd credish
|
|
59
|
+
python -m venv .venv
|
|
60
|
+
source .venv/bin/activate
|
|
61
|
+
python -m pip install -e ".[dev]"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
On Windows PowerShell:
|
|
65
|
+
|
|
66
|
+
```powershell
|
|
67
|
+
cd credish
|
|
68
|
+
python -m venv .venv
|
|
69
|
+
.\.venv\Scripts\Activate.ps1
|
|
70
|
+
python -m pip install -e ".[dev]"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
To rebuild the extension in place:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
python setup.py build_ext --inplace
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Quick Start
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from credish import CredishClient, PERSISTENCE
|
|
83
|
+
|
|
84
|
+
with CredishClient(data_dir="./data", persistence=PERSISTENCE.HYBRID) as client:
|
|
85
|
+
assert client.ping() == "PONG"
|
|
86
|
+
|
|
87
|
+
client.set("name", "credish")
|
|
88
|
+
assert client.get("name") == b"credish"
|
|
89
|
+
assert client.get("name", native=True) == "credish"
|
|
90
|
+
|
|
91
|
+
client.incrby("visits", 1)
|
|
92
|
+
assert client.get("visits") == b"1"
|
|
93
|
+
|
|
94
|
+
client.rpush("queue", "first", "second")
|
|
95
|
+
assert client.lrange("queue", 0, -1) == [b"first", b"second"]
|
|
96
|
+
|
|
97
|
+
client.zadd("leaders", {"ann": 10, "bob": 20})
|
|
98
|
+
assert client.zrange("leaders", 0, -1, withscores=True) == [
|
|
99
|
+
(b"ann", 10.0),
|
|
100
|
+
(b"bob", 20.0),
|
|
101
|
+
]
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Redis-style read methods return `bytes` by default. Use `get(..., native=True)`
|
|
105
|
+
to decode values that were stored from supported Python types such as `str`,
|
|
106
|
+
`int`, `float`, `bool`, `None`, lists, or dictionaries.
|
|
107
|
+
|
|
108
|
+
## Client Configuration
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from credish import AOF_FSYNC, CredishClient, PERSISTENCE
|
|
112
|
+
|
|
113
|
+
client = CredishClient(
|
|
114
|
+
data_dir=".",
|
|
115
|
+
persistence=PERSISTENCE.HYBRID,
|
|
116
|
+
save_interval=300,
|
|
117
|
+
aof_fsync=AOF_FSYNC.EVERYSEC,
|
|
118
|
+
db=0,
|
|
119
|
+
)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
| Parameter | Default | Description |
|
|
123
|
+
| --- | --- | --- |
|
|
124
|
+
| `data_dir` | `"."` | Directory for `credish.rdb` and `credish.aof`. |
|
|
125
|
+
| `persistence` | `"hybrid"` | One of `"none"`, `"rdb"`, `"aof"`, or `"hybrid"`. |
|
|
126
|
+
| `save_interval` | `300` | Seconds between automatic RDB snapshots where applicable. |
|
|
127
|
+
| `aof_fsync` | `"everysec"` | One of `"always"`, `"everysec"`, or `"no"`. |
|
|
128
|
+
| `db` | `0` | Initial logical database index, from `0` to `15`. |
|
|
129
|
+
|
|
130
|
+
Prefer using `CredishClient` as a context manager:
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from credish import CredishClient
|
|
134
|
+
|
|
135
|
+
with CredishClient() as client:
|
|
136
|
+
client.set("ready", "yes")
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Supported Commands
|
|
140
|
+
|
|
141
|
+
Implemented command groups include:
|
|
142
|
+
|
|
143
|
+
| Group | Commands |
|
|
144
|
+
| --- | --- |
|
|
145
|
+
| Server | `ping`, `flushdb`, `dbsize`, `select`, `save`, `bgsave` |
|
|
146
|
+
| Keys and expiry | `delete`, `exists`, `expire`, `pexpire`, `persist`, `ttl`, `pttl`, `type` |
|
|
147
|
+
| Strings | `set`, `get`, `incr`, `incrby`, `decr`, `decrby` |
|
|
148
|
+
| Lists | `lpush`, `rpush`, `lrange`, `llen` |
|
|
149
|
+
| Sorted sets | `zadd`, `zrange`, `zrevrange`, `zrank`, `zrevrank`, `zscore`, `zrem`, `zcard`, `zrangebyscore`, `zincrby` |
|
|
150
|
+
|
|
151
|
+
Some Python wrapper methods are present ahead of their C extension exports. See
|
|
152
|
+
[Errors and Limitations](https://github.com/Ravisxcr/credish/blob/main/docs/errors-and-limitations.md) for the current gaps.
|
|
153
|
+
|
|
154
|
+
## Persistence
|
|
155
|
+
|
|
156
|
+
Credish can store data in the configured `data_dir` using:
|
|
157
|
+
|
|
158
|
+
| Mode | Behavior |
|
|
159
|
+
| --- | --- |
|
|
160
|
+
| `none` | Keep data only in memory. |
|
|
161
|
+
| `rdb` | Use point-in-time snapshots. |
|
|
162
|
+
| `aof` | Append write operations to an AOF log. |
|
|
163
|
+
| `hybrid` | Use both RDB snapshots and AOF logging. |
|
|
164
|
+
|
|
165
|
+
The generated files are named `credish.rdb` and `credish.aof`.
|
|
166
|
+
|
|
167
|
+
## Project Status
|
|
168
|
+
|
|
169
|
+
Credish is not a network Redis server and does not implement the Redis protocol.
|
|
170
|
+
It is designed as an embedded cache with Redis-like command semantics for common
|
|
171
|
+
workflows.
|
|
172
|
+
|
|
173
|
+
Current limitations:
|
|
174
|
+
|
|
175
|
+
- Hash and set command groups are planned but not currently implemented in the C
|
|
176
|
+
extension.
|
|
177
|
+
- Several Redis string and list wrappers exist in Python before their C
|
|
178
|
+
extension counterparts.
|
|
179
|
+
- Redis compatibility focuses on common command behavior, not complete Redis
|
|
180
|
+
server behavior.
|
|
181
|
+
|
|
182
|
+
See [Errors and Limitations](https://github.com/Ravisxcr/credish/blob/main/docs/errors-and-limitations.md) for more detail.
|
|
183
|
+
|
|
184
|
+
## Development
|
|
185
|
+
|
|
186
|
+
Run the unit tests:
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
pytest tests/unit
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Run the full test suite, including stress tests:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
pytest
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Build a source distribution and wheel:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
python -m build
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Documentation
|
|
205
|
+
|
|
206
|
+
- [Getting Started](https://github.com/Ravisxcr/credish/blob/main/docs/getting-started.md)
|
|
207
|
+
- [API Reference](https://github.com/Ravisxcr/credish/blob/main/docs/api-reference.md)
|
|
208
|
+
- [Persistence and Expiry](https://github.com/Ravisxcr/credish/blob/main/docs/persistence-and-expiry.md)
|
|
209
|
+
- [Internals](https://github.com/Ravisxcr/credish/blob/main/docs/internals.md)
|
|
210
|
+
- [Errors and Limitations](https://github.com/Ravisxcr/credish/blob/main/docs/errors-and-limitations.md)
|
|
211
|
+
- [Development](https://github.com/Ravisxcr/credish/blob/main/docs/development.md)
|
|
212
|
+
|
|
213
|
+
## License
|
|
214
|
+
|
|
215
|
+
Credish is licensed under the MIT License. See [LICENSE](https://github.com/Ravisxcr/credish/blob/main/LICENSE) for details.
|
|
216
|
+
|
credish-0.0.2/README.md
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# Credish
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/credish/)
|
|
4
|
+
[](https://pypi.org/project/credish/)
|
|
5
|
+
[](https://github.com/Ravisxcr/credish/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
Credish is a Redis-compatible, in-process cache for Python. It provides a
|
|
8
|
+
`redis-py`-style client backed by a native C extension, so applications can use
|
|
9
|
+
familiar Redis commands without running a separate Redis server process.
|
|
10
|
+
|
|
11
|
+
Credish is currently early-stage. The main supported areas are strings, lists,
|
|
12
|
+
sorted sets, key expiry, logical databases, and local persistence.
|
|
13
|
+
|
|
14
|
+
## Why Credish?
|
|
15
|
+
|
|
16
|
+
- In-process cache with no Redis server process to manage
|
|
17
|
+
- Native C storage engine exposed through a small Python API
|
|
18
|
+
- Redis-like commands for common strings, lists, sorted sets, keys, and expiry
|
|
19
|
+
- Logical database selection with indexes `0` through `15`
|
|
20
|
+
- Persistence modes for no persistence, RDB snapshots, AOF logs, or both
|
|
21
|
+
- Context-manager client support for clean native resource handling
|
|
22
|
+
- Python 3.10+ packaging with editable installs and wheel build support
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
Credish builds a C extension, so you need Python 3.10 or newer and a C
|
|
27
|
+
compiler. On Linux and macOS the compiler must support POSIX threads; on
|
|
28
|
+
Windows, native threading APIs are used instead.
|
|
29
|
+
|
|
30
|
+
Install from PyPI:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
python -m pip install credish
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For local development, install the package in editable mode with development
|
|
37
|
+
dependencies:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cd credish
|
|
41
|
+
python -m venv .venv
|
|
42
|
+
source .venv/bin/activate
|
|
43
|
+
python -m pip install -e ".[dev]"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
On Windows PowerShell:
|
|
47
|
+
|
|
48
|
+
```powershell
|
|
49
|
+
cd credish
|
|
50
|
+
python -m venv .venv
|
|
51
|
+
.\.venv\Scripts\Activate.ps1
|
|
52
|
+
python -m pip install -e ".[dev]"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
To rebuild the extension in place:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
python setup.py build_ext --inplace
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Quick Start
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from credish import CredishClient, PERSISTENCE
|
|
65
|
+
|
|
66
|
+
with CredishClient(data_dir="./data", persistence=PERSISTENCE.HYBRID) as client:
|
|
67
|
+
assert client.ping() == "PONG"
|
|
68
|
+
|
|
69
|
+
client.set("name", "credish")
|
|
70
|
+
assert client.get("name") == b"credish"
|
|
71
|
+
assert client.get("name", native=True) == "credish"
|
|
72
|
+
|
|
73
|
+
client.incrby("visits", 1)
|
|
74
|
+
assert client.get("visits") == b"1"
|
|
75
|
+
|
|
76
|
+
client.rpush("queue", "first", "second")
|
|
77
|
+
assert client.lrange("queue", 0, -1) == [b"first", b"second"]
|
|
78
|
+
|
|
79
|
+
client.zadd("leaders", {"ann": 10, "bob": 20})
|
|
80
|
+
assert client.zrange("leaders", 0, -1, withscores=True) == [
|
|
81
|
+
(b"ann", 10.0),
|
|
82
|
+
(b"bob", 20.0),
|
|
83
|
+
]
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Redis-style read methods return `bytes` by default. Use `get(..., native=True)`
|
|
87
|
+
to decode values that were stored from supported Python types such as `str`,
|
|
88
|
+
`int`, `float`, `bool`, `None`, lists, or dictionaries.
|
|
89
|
+
|
|
90
|
+
## Client Configuration
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from credish import AOF_FSYNC, CredishClient, PERSISTENCE
|
|
94
|
+
|
|
95
|
+
client = CredishClient(
|
|
96
|
+
data_dir=".",
|
|
97
|
+
persistence=PERSISTENCE.HYBRID,
|
|
98
|
+
save_interval=300,
|
|
99
|
+
aof_fsync=AOF_FSYNC.EVERYSEC,
|
|
100
|
+
db=0,
|
|
101
|
+
)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
| Parameter | Default | Description |
|
|
105
|
+
| --- | --- | --- |
|
|
106
|
+
| `data_dir` | `"."` | Directory for `credish.rdb` and `credish.aof`. |
|
|
107
|
+
| `persistence` | `"hybrid"` | One of `"none"`, `"rdb"`, `"aof"`, or `"hybrid"`. |
|
|
108
|
+
| `save_interval` | `300` | Seconds between automatic RDB snapshots where applicable. |
|
|
109
|
+
| `aof_fsync` | `"everysec"` | One of `"always"`, `"everysec"`, or `"no"`. |
|
|
110
|
+
| `db` | `0` | Initial logical database index, from `0` to `15`. |
|
|
111
|
+
|
|
112
|
+
Prefer using `CredishClient` as a context manager:
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from credish import CredishClient
|
|
116
|
+
|
|
117
|
+
with CredishClient() as client:
|
|
118
|
+
client.set("ready", "yes")
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Supported Commands
|
|
122
|
+
|
|
123
|
+
Implemented command groups include:
|
|
124
|
+
|
|
125
|
+
| Group | Commands |
|
|
126
|
+
| --- | --- |
|
|
127
|
+
| Server | `ping`, `flushdb`, `dbsize`, `select`, `save`, `bgsave` |
|
|
128
|
+
| Keys and expiry | `delete`, `exists`, `expire`, `pexpire`, `persist`, `ttl`, `pttl`, `type` |
|
|
129
|
+
| Strings | `set`, `get`, `incr`, `incrby`, `decr`, `decrby` |
|
|
130
|
+
| Lists | `lpush`, `rpush`, `lrange`, `llen` |
|
|
131
|
+
| Sorted sets | `zadd`, `zrange`, `zrevrange`, `zrank`, `zrevrank`, `zscore`, `zrem`, `zcard`, `zrangebyscore`, `zincrby` |
|
|
132
|
+
|
|
133
|
+
Some Python wrapper methods are present ahead of their C extension exports. See
|
|
134
|
+
[Errors and Limitations](https://github.com/Ravisxcr/credish/blob/main/docs/errors-and-limitations.md) for the current gaps.
|
|
135
|
+
|
|
136
|
+
## Persistence
|
|
137
|
+
|
|
138
|
+
Credish can store data in the configured `data_dir` using:
|
|
139
|
+
|
|
140
|
+
| Mode | Behavior |
|
|
141
|
+
| --- | --- |
|
|
142
|
+
| `none` | Keep data only in memory. |
|
|
143
|
+
| `rdb` | Use point-in-time snapshots. |
|
|
144
|
+
| `aof` | Append write operations to an AOF log. |
|
|
145
|
+
| `hybrid` | Use both RDB snapshots and AOF logging. |
|
|
146
|
+
|
|
147
|
+
The generated files are named `credish.rdb` and `credish.aof`.
|
|
148
|
+
|
|
149
|
+
## Project Status
|
|
150
|
+
|
|
151
|
+
Credish is not a network Redis server and does not implement the Redis protocol.
|
|
152
|
+
It is designed as an embedded cache with Redis-like command semantics for common
|
|
153
|
+
workflows.
|
|
154
|
+
|
|
155
|
+
Current limitations:
|
|
156
|
+
|
|
157
|
+
- Hash and set command groups are planned but not currently implemented in the C
|
|
158
|
+
extension.
|
|
159
|
+
- Several Redis string and list wrappers exist in Python before their C
|
|
160
|
+
extension counterparts.
|
|
161
|
+
- Redis compatibility focuses on common command behavior, not complete Redis
|
|
162
|
+
server behavior.
|
|
163
|
+
|
|
164
|
+
See [Errors and Limitations](https://github.com/Ravisxcr/credish/blob/main/docs/errors-and-limitations.md) for more detail.
|
|
165
|
+
|
|
166
|
+
## Development
|
|
167
|
+
|
|
168
|
+
Run the unit tests:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
pytest tests/unit
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Run the full test suite, including stress tests:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
pytest
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Build a source distribution and wheel:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
python -m build
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Documentation
|
|
187
|
+
|
|
188
|
+
- [Getting Started](https://github.com/Ravisxcr/credish/blob/main/docs/getting-started.md)
|
|
189
|
+
- [API Reference](https://github.com/Ravisxcr/credish/blob/main/docs/api-reference.md)
|
|
190
|
+
- [Persistence and Expiry](https://github.com/Ravisxcr/credish/blob/main/docs/persistence-and-expiry.md)
|
|
191
|
+
- [Internals](https://github.com/Ravisxcr/credish/blob/main/docs/internals.md)
|
|
192
|
+
- [Errors and Limitations](https://github.com/Ravisxcr/credish/blob/main/docs/errors-and-limitations.md)
|
|
193
|
+
- [Development](https://github.com/Ravisxcr/credish/blob/main/docs/development.md)
|
|
194
|
+
|
|
195
|
+
## License
|
|
196
|
+
|
|
197
|
+
Credish is licensed under the MIT License. See [LICENSE](https://github.com/Ravisxcr/credish/blob/main/LICENSE) for details.
|
|
198
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from credish.client import CredishClient
|
|
2
|
+
from credish.constants import AOF_FSYNC, PERSISTENCE
|
|
3
|
+
from credish.exceptions import CredishError, ResponseError, DataError, WrongTypeError
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"CredishClient",
|
|
7
|
+
"PERSISTENCE",
|
|
8
|
+
"AOF_FSYNC",
|
|
9
|
+
"CredishError",
|
|
10
|
+
"ResponseError",
|
|
11
|
+
"DataError",
|
|
12
|
+
"WrongTypeError",
|
|
13
|
+
]
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Type stubs for the _credish C extension."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Optional
|
|
4
|
+
|
|
5
|
+
# The db handle is an opaque capsule
|
|
6
|
+
class _Store: ...
|
|
7
|
+
_SessionHandle = _Store | tuple[_Store, int]
|
|
8
|
+
|
|
9
|
+
def open(
|
|
10
|
+
data_dir: str = ".",
|
|
11
|
+
persistence: str = "hybrid",
|
|
12
|
+
save_interval: int = 300,
|
|
13
|
+
aof_fsync: str = "everysec",
|
|
14
|
+
db: int = 0,
|
|
15
|
+
) -> _Store: ...
|
|
16
|
+
|
|
17
|
+
def close(handle: _SessionHandle) -> None: ...
|
|
18
|
+
def ping(handle: _SessionHandle) -> str: ...
|
|
19
|
+
def flushdb(handle: _SessionHandle) -> bool: ...
|
|
20
|
+
def dbsize(handle: _SessionHandle, db: int = 0) -> int: ...
|
|
21
|
+
def save(handle: _SessionHandle) -> bool: ...
|
|
22
|
+
def bgsave(handle: _SessionHandle) -> bool: ...
|
|
23
|
+
def select(handle: _SessionHandle, db: int) -> bool: ...
|
|
24
|
+
|
|
25
|
+
# String
|
|
26
|
+
def get(handle: _SessionHandle, key: str | bytes) -> bytes | None: ...
|
|
27
|
+
def get_encoding(handle: _SessionHandle, key: str | bytes) -> int | None: ...
|
|
28
|
+
def set(
|
|
29
|
+
handle: _SessionHandle,
|
|
30
|
+
key: str | bytes,
|
|
31
|
+
value: str | bytes | int | float,
|
|
32
|
+
ex: int = -1,
|
|
33
|
+
px: int = -1,
|
|
34
|
+
nx: bool = False,
|
|
35
|
+
xx: bool = False,
|
|
36
|
+
value_encoding: int = 0,
|
|
37
|
+
) -> bool | None: ...
|
|
38
|
+
def delete(handle: _SessionHandle, keys: list[str | bytes]) -> int: ...
|
|
39
|
+
def exists(handle: _SessionHandle, keys: list[str | bytes]) -> int: ...
|
|
40
|
+
def expire(handle: _SessionHandle, key: str | bytes, seconds: int) -> bool: ...
|
|
41
|
+
def pexpire(handle: _SessionHandle, key: str | bytes, milliseconds: int) -> bool: ...
|
|
42
|
+
def persist(handle: _SessionHandle, key: str | bytes) -> bool: ...
|
|
43
|
+
def ttl(handle: _SessionHandle, key: str | bytes) -> int: ...
|
|
44
|
+
def pttl(handle: _SessionHandle, key: str | bytes) -> int: ...
|
|
45
|
+
def type_(handle: _SessionHandle, key: str | bytes) -> str: ...
|
|
46
|
+
def incrby(handle: _SessionHandle, key: str | bytes, amount: int) -> int: ...
|
|
47
|
+
|
|
48
|
+
# List
|
|
49
|
+
def lpush(handle: _SessionHandle, key: str | bytes, values: list[Any]) -> int: ...
|
|
50
|
+
def rpush(handle: _SessionHandle, key: str | bytes, values: list[Any]) -> int: ...
|
|
51
|
+
def lrange(handle: _SessionHandle, key: str | bytes, start: int, stop: int) -> list[bytes]: ...
|
|
52
|
+
def llen(handle: _SessionHandle, key: str | bytes) -> int: ...
|