Name | pyinmem JSON |
Version |
1
JSON |
| download |
home_page | |
Summary | Python in-memory database |
upload_time | 2024-02-25 16:51:39 |
maintainer | |
docs_url | None |
author | Your Name |
requires_python | >=3.11,<4.0 |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# PyInMemStore
PyInMemStore is a lightweight, in-memory data store written in Python. It provides a simple way to store and manipulate data structures such as strings, lists, sets, and sorted sets. The store offers thread-safe operations and supports key expiry, similar to Redis.
## Features
- Basic data types: Strings, Lists, Sets, and Sorted Sets.
- Thread-safe operations.
- Key expiry functionality.
- Dynamic method dispatching based on data type.
- Easy extensibility for additional data types and operations.
## Data Types and Operations
### String
- `set(key, value, ttl=None)`: Set a string value under a key. Optionally, specify a Time-To-Live (TTL) in seconds.
- `get(key)`: Retrieve the string value for a given key.
### List
- `lpush(key, value)`: Push a value to the beginning of a list at a given key.
- `rpop(key)`: Pop a value from the end of a list at a given key.
- `llen(key)`: Get the length of the list at a given key.
### Set
- `sadd(key, *values)`: Add one or more values to a set at a given key.
- `srem(key, *values)`: Remove one or more values from a set at a given key.
- `smembers(key)`: Get all the members of the set at a given key.
- `sis_member(key, value)`: Check if a value is a member of the set at a given key.
### Sorted Set
- `zadd(key, scores)`: Add one or more member-score pairs to a sorted set at a given key.
- `zrange(key, start, stop)`: Get a range of members from a sorted set at a given key, sorted by score.
- `zscore(key, member)`: Get the score of a member in a sorted set at a given key.
## Usage
```python
from pyinmemstore import PyInMemStore
store = PyInMemStore(save_data=True)
store.set('hello', 'world')
print(store.get('hello'))
store.lpush('mylist', 'hello')
store.lpush('mylist', 'world')
print(store.rpop('mylist'))
store.sadd('myset', 'hello', 'world')
print(store.smembers('myset'))
store.zadd('my_sorted_set', {'Alice': 100, 'Bob': 90})
print(store.zrange('my_sorted_set', 0, -1))
print(store.zscore('my_sorted_set', 'Alice'))
Raw data
{
"_id": null,
"home_page": "",
"name": "pyinmem",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.11,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Your Name",
"author_email": "you@example.com",
"download_url": "https://files.pythonhosted.org/packages/61/70/7c520d947f60fb622ca6d76071785da47c251526f281abb6ef6dc34b1f96/pyinmem-1.tar.gz",
"platform": null,
"description": "# PyInMemStore\n\nPyInMemStore is a lightweight, in-memory data store written in Python. It provides a simple way to store and manipulate data structures such as strings, lists, sets, and sorted sets. The store offers thread-safe operations and supports key expiry, similar to Redis.\n\n## Features\n\n- Basic data types: Strings, Lists, Sets, and Sorted Sets.\n- Thread-safe operations.\n- Key expiry functionality.\n- Dynamic method dispatching based on data type.\n- Easy extensibility for additional data types and operations.\n\n## Data Types and Operations\n\n### String\n\n- `set(key, value, ttl=None)`: Set a string value under a key. Optionally, specify a Time-To-Live (TTL) in seconds.\n- `get(key)`: Retrieve the string value for a given key.\n\n### List\n\n- `lpush(key, value)`: Push a value to the beginning of a list at a given key.\n- `rpop(key)`: Pop a value from the end of a list at a given key.\n- `llen(key)`: Get the length of the list at a given key.\n\n### Set\n\n- `sadd(key, *values)`: Add one or more values to a set at a given key.\n- `srem(key, *values)`: Remove one or more values from a set at a given key.\n- `smembers(key)`: Get all the members of the set at a given key.\n- `sis_member(key, value)`: Check if a value is a member of the set at a given key.\n\n### Sorted Set\n\n- `zadd(key, scores)`: Add one or more member-score pairs to a sorted set at a given key.\n- `zrange(key, start, stop)`: Get a range of members from a sorted set at a given key, sorted by score.\n- `zscore(key, member)`: Get the score of a member in a sorted set at a given key.\n\n## Usage\n\n```python\nfrom pyinmemstore import PyInMemStore\n\nstore = PyInMemStore(save_data=True)\n\n\nstore.set('hello', 'world')\nprint(store.get('hello'))\n\n\nstore.lpush('mylist', 'hello')\nstore.lpush('mylist', 'world')\nprint(store.rpop('mylist'))\n\n\nstore.sadd('myset', 'hello', 'world')\nprint(store.smembers('myset'))\n\n\nstore.zadd('my_sorted_set', {'Alice': 100, 'Bob': 90})\nprint(store.zrange('my_sorted_set', 0, -1))\nprint(store.zscore('my_sorted_set', 'Alice'))\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Python in-memory database",
"version": "1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "91a891910419c2a42f7196c5267b34c8bb97151be1bd310a38e93e1d0d70ae0d",
"md5": "7d33c72ebf596858e864b077357a0c84",
"sha256": "c38461168371d03e42c2d7f9204351ff1c623b7a1f3144d47d8f732b741e4e40"
},
"downloads": -1,
"filename": "pyinmem-1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7d33c72ebf596858e864b077357a0c84",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11,<4.0",
"size": 8935,
"upload_time": "2024-02-25T16:51:37",
"upload_time_iso_8601": "2024-02-25T16:51:37.212152Z",
"url": "https://files.pythonhosted.org/packages/91/a8/91910419c2a42f7196c5267b34c8bb97151be1bd310a38e93e1d0d70ae0d/pyinmem-1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "61707c520d947f60fb622ca6d76071785da47c251526f281abb6ef6dc34b1f96",
"md5": "99f28fc6f804bb78936784fec699fefc",
"sha256": "da71c021310e5f544f32947a664ea4193feb751c8be0eb491ee99d8390eb856d"
},
"downloads": -1,
"filename": "pyinmem-1.tar.gz",
"has_sig": false,
"md5_digest": "99f28fc6f804bb78936784fec699fefc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11,<4.0",
"size": 7257,
"upload_time": "2024-02-25T16:51:39",
"upload_time_iso_8601": "2024-02-25T16:51:39.010110Z",
"url": "https://files.pythonhosted.org/packages/61/70/7c520d947f60fb622ca6d76071785da47c251526f281abb6ef6dc34b1f96/pyinmem-1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-25 16:51:39",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pyinmem"
}