valkeylite 9.0.0__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.
@@ -0,0 +1,54 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Cyborg Inc.
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.
22
+
23
+ ---
24
+
25
+ This project bundles Valkey (https://github.com/valkey-io/valkey), which is
26
+ licensed under the BSD 3-Clause License:
27
+
28
+ Copyright (c) 2024, Valkey contributors
29
+ All rights reserved.
30
+
31
+ Redistribution and use in source and binary forms, with or without
32
+ modification, are permitted provided that the following conditions are met:
33
+
34
+ 1. Redistributions of source code must retain the above copyright notice,
35
+ this list of conditions and the following disclaimer.
36
+
37
+ 2. Redistributions in binary form must reproduce the above copyright notice,
38
+ this list of conditions and the following disclaimer in the documentation
39
+ and/or other materials provided with the distribution.
40
+
41
+ 3. Neither the name of the copyright holder nor the names of its contributors
42
+ may be used to endorse or promote products derived from this software
43
+ without specific prior written permission.
44
+
45
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
46
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
49
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
52
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,356 @@
1
+ Metadata-Version: 2.4
2
+ Name: valkeylite
3
+ Version: 9.0.0
4
+ Summary: Embedded Valkey server for Python - like redislite but with Valkey!
5
+ Author: Cyborg Inc., Nicolas Dupont
6
+ Maintainer: Cyborg Inc.
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/cyborginc/valkeylite
9
+ Project-URL: Repository, https://github.com/cyborginc/valkeylite
10
+ Project-URL: Issues, https://github.com/cyborginc/valkeylite/issues
11
+ Keywords: valkey,redis,server,testing,development,embedded,database,cache
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: MacOS :: MacOS X
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Programming Language :: Python :: Implementation :: CPython
23
+ Classifier: Topic :: Database
24
+ Classifier: Topic :: Software Development :: Testing
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Requires-Python: >=3.10
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: valkey>=6.0
30
+ Provides-Extra: test
31
+ Requires-Dist: pytest>=7.0; extra == "test"
32
+ Requires-Dist: pytest-timeout; extra == "test"
33
+ Dynamic: license-file
34
+
35
+ # valkeylite
36
+
37
+ [![PyPI version](https://img.shields.io/pypi/v/valkeylite.svg)](https://pypi.org/project/valkeylite/)
38
+ [![Python versions](https://img.shields.io/pypi/pyversions/valkeylite.svg)](https://pypi.org/project/valkeylite/)
39
+ [![License](https://img.shields.io/pypi/l/valkeylite.svg)](https://github.com/cyborginc/valkeylite/blob/main/LICENSE)
40
+ [![Sponsored by Cyborg Inc.](https://img.shields.io/badge/Sponsored%20by-Cyborg%20Inc.-blue)](https://www.cyborg.co)
41
+
42
+ **Install and run Valkey directly from Python**
43
+
44
+ `valkeylite` is a Python package that bundles the [Valkey](https://valkey.io/) server (the open-source continuation of Redis) as a library. It provides an embedded Valkey server that can be started and stopped from Python code, eliminating the need for external Valkey installations or Docker containers during development and testing.
45
+
46
+ It's like [`redislite`](https://github.com/yahoo/redislite) but with Valkey!
47
+
48
+ ## Features
49
+
50
+ - 🚀 **Drop-in replacement** for redislite with Valkey
51
+ - 🔧 **Two APIs** - Simple client wrapper OR explicit server control
52
+ - 🧪 **Perfect for testing** - Isolated instances with auto-cleanup
53
+ - ⚡ **Latest Valkey** - Currently bundles Valkey 9.0.0
54
+ - 🎯 **Pytest fixtures** - Built-in pytest integration
55
+ - 🔓 **Open source** - MIT license, bundles BSD-3-Clause Valkey
56
+
57
+ ## Supported Platforms
58
+
59
+ | Platform | Architecture | Status |
60
+ |----------|--------------|--------|
61
+ | **Linux** | x86_64 | ✅ Supported |
62
+ | **Linux** | aarch64 (ARM64) | ✅ Supported |
63
+ | **macOS** | x86_64 (Intel) | ✅ Supported |
64
+ | **macOS** | arm64 (Apple Silicon) | ✅ Supported |
65
+ | **Windows** | - | ❌ Not supported |
66
+
67
+ ## Installation
68
+
69
+ ```bash
70
+ pip install valkeylite
71
+ ```
72
+
73
+ Includes valkey-py client automatically. For testing extras:
74
+
75
+ ```bash
76
+ pip install valkeylite[test]
77
+ ```
78
+
79
+ ## Quick Start
80
+
81
+ ### Client API (Like redislite)
82
+
83
+ ```python
84
+ from valkeylite import Valkey
85
+
86
+ # Just works - server starts automatically
87
+ r = Valkey()
88
+ r.set('key', 'value')
89
+ assert r.get('key') == b'value'
90
+ r.close()
91
+
92
+ # Or with context manager
93
+ with Valkey() as r:
94
+ r.set('key', 'value')
95
+ assert r.get('key') == b'value'
96
+
97
+ # With persistence
98
+ r = Valkey('/tmp/mydata.db')
99
+ r.set('key', 'value')
100
+ r.close()
101
+ ```
102
+
103
+ ### Server API
104
+
105
+ ```python
106
+ from valkeylite import ValkeyServer
107
+
108
+ # Full control over server lifecycle
109
+ with ValkeyServer() as server:
110
+ print(f"Valkey running at {server.host}:{server.port}")
111
+
112
+ # Use built-in client
113
+ client = server.client()
114
+ client.set('key', 'value')
115
+
116
+ # Or bring your own (any Redis-compatible client)
117
+ import aredis
118
+ client = aredis.Redis(**server.connection_kwargs)
119
+ ```
120
+
121
+ ### Pytest Integration
122
+
123
+ ```python
124
+ # Automatically available with valkeylite[test]
125
+
126
+ def test_with_server(valkeylite):
127
+ """Use the server fixture."""
128
+ import valkey
129
+ client = valkey.Valkey(**valkeylite.connection_kwargs)
130
+ client.set('test', 'data')
131
+ assert client.get('test') == b'data'
132
+
133
+ def test_with_client(valkey_client):
134
+ """Use the pre-configured client fixture."""
135
+ valkey_client.set('test', 'data')
136
+ assert valkey_client.get('test') == b'data'
137
+ ```
138
+
139
+ ### Command-Line Interface
140
+
141
+ ```bash
142
+ # Start server in foreground
143
+ valkeylite
144
+
145
+ # Or with python -m
146
+ python -m valkeylite
147
+
148
+ # Specify port
149
+ valkeylite --port 6380
150
+
151
+ # See all options
152
+ valkeylite --help
153
+ ```
154
+
155
+ ## Advanced Usage
156
+
157
+ ### Custom Configuration
158
+
159
+ ```python
160
+ from valkeylite import ValkeyServer
161
+ from pathlib import Path
162
+
163
+ server = ValkeyServer(
164
+ port=6380, # Specific port (None = auto-assign)
165
+ host='127.0.0.1', # Bind address
166
+ data_dir=Path('/tmp/valkey'), # Data directory (None = temp)
167
+ persist=True, # Keep data after shutdown
168
+ config={
169
+ 'maxmemory': '100mb',
170
+ 'maxmemory-policy': 'allkeys-lru',
171
+ 'loglevel': 'debug',
172
+ }
173
+ )
174
+
175
+ server.start()
176
+ # ... use server ...
177
+ server.stop()
178
+ ```
179
+
180
+ ### Multiple Instances
181
+
182
+ ```python
183
+ from valkeylite import ValkeyServer
184
+
185
+ # Run multiple isolated servers
186
+ with ValkeyServer(port=6379) as server1:
187
+ with ValkeyServer(port=6380) as server2:
188
+ # Two independent Valkey instances
189
+ client1 = server1.client()
190
+ client2 = server2.client()
191
+ ```
192
+
193
+ ### Manual Lifecycle Management
194
+
195
+ ```python
196
+ from valkeylite import ValkeyServer
197
+
198
+ server = ValkeyServer()
199
+ server.start(timeout=10.0) # Wait up to 10s for startup
200
+
201
+ try:
202
+ # Use server
203
+ print(f"Server running: {server.is_running()}")
204
+ print(f"Connection URL: {server.connection_url}")
205
+ finally:
206
+ server.stop() # Graceful shutdown
207
+ # or server.terminate() for immediate kill
208
+ ```
209
+
210
+ ## API Reference
211
+
212
+ ### Valkey (Client API)
213
+
214
+ ```python
215
+ class Valkey(valkey.Valkey):
216
+ """
217
+ Valkey client with embedded server (like redislite.Redis).
218
+
219
+ Inherits all methods from valkey.Valkey client.
220
+ """
221
+
222
+ def __init__(
223
+ self,
224
+ dbfilename: Optional[Path] = None,
225
+ host: str = "127.0.0.1",
226
+ port: Optional[int] = None,
227
+ **kwargs: Any,
228
+ ) -> None:
229
+ """
230
+ Initialize client with embedded server.
231
+
232
+ Args:
233
+ dbfilename: Path for persistent data (None = temporary)
234
+ host: Host to bind to
235
+ port: Port to bind to (None = auto-assign)
236
+ **kwargs: Additional valkey.Valkey arguments
237
+ """
238
+
239
+ @property
240
+ def server(self) -> ValkeyServer:
241
+ """Access underlying ValkeyServer instance."""
242
+ ```
243
+
244
+ ### ValkeyServer (Server API)
245
+
246
+ ```python
247
+ class ValkeyServer:
248
+ """Explicit server lifecycle management."""
249
+
250
+ def __init__(
251
+ self,
252
+ port: Optional[int] = None,
253
+ host: str = "127.0.0.1",
254
+ data_dir: Optional[Path] = None,
255
+ config: Optional[Dict[str, Any]] = None,
256
+ persist: bool = False,
257
+ **config_overrides: Any,
258
+ ) -> None:
259
+ """Initialize Valkey server instance."""
260
+
261
+ def start(self, timeout: float = 10.0) -> None:
262
+ """Start server and wait until ready."""
263
+
264
+ def stop(self, timeout: float = 5.0) -> None:
265
+ """Gracefully stop server."""
266
+
267
+ def client(self, **kwargs: Any) -> valkey.Valkey:
268
+ """Create valkey-py client connected to this server."""
269
+
270
+ @property
271
+ def port(self) -> int:
272
+ """Get server port."""
273
+
274
+ @property
275
+ def connection_kwargs(self) -> Dict[str, Any]:
276
+ """Get connection parameters for any client."""
277
+ ```
278
+
279
+ ### Pytest Fixtures
280
+
281
+ ```python
282
+ # Available with pip install valkeylite[test]
283
+
284
+ @pytest.fixture
285
+ def valkeylite() -> ValkeyServer:
286
+ """Provides ValkeyServer instance."""
287
+
288
+ @pytest.fixture
289
+ def valkey_client(valkeylite) -> valkey.Valkey:
290
+ """Provides connected valkey-py client."""
291
+
292
+ @pytest.fixture
293
+ def valkey_url(valkeylite) -> str:
294
+ """Provides connection URL string."""
295
+ ```
296
+
297
+ ## Migration from redislite
298
+
299
+ ```python
300
+ # Before
301
+ from redislite import Redis
302
+ r = Redis()
303
+ r.set('key', 'value')
304
+
305
+ # After
306
+ from valkeylite import Valkey
307
+ r = Valkey()
308
+ r.set('key', 'value')
309
+ ```
310
+
311
+ **With persistence:**
312
+
313
+ ```python
314
+ # Before
315
+ from redislite import Redis
316
+ r = Redis('/tmp/redis.db')
317
+
318
+ # After
319
+ from valkeylite import Valkey
320
+ r = Valkey('/tmp/redis.db')
321
+ ```
322
+
323
+ ## Development
324
+
325
+ ```bash
326
+ # Clone repository
327
+ git clone https://github.com/cyborginc/valkeylite.git
328
+ cd valkeylite
329
+
330
+ # Install in development mode
331
+ pip install -e .[test]
332
+
333
+ # Run tests
334
+ pytest
335
+ ```
336
+
337
+ ## Contributing
338
+
339
+ Contributions welcome! Please:
340
+
341
+ 1. Open an issue for bugs or feature requests
342
+ 2. Submit PRs with tests and documentation
343
+ 3. Follow existing code style
344
+
345
+ ## License
346
+
347
+ MIT License - see [LICENSE](LICENSE) file
348
+
349
+ Valkey is licensed under BSD 3-Clause License
350
+
351
+ ## Acknowledgments
352
+
353
+ This project is sponsored and maintained by [Cyborg Inc.](https://www.cyborg.co)
354
+
355
+ - Built on [Valkey](https://valkey.io/), the open-source continuation of Redis
356
+ - Inspired by [redislite](https://github.com/yahoo/redislite)