Name | pyttldict JSON |
Version |
1.0.0
JSON |
| download |
home_page | |
Summary | Python Dictionary with timed expiring keys |
upload_time | 2024-02-15 08:24:58 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.9 |
license | MIT License Copyright (c) 2024 Gurjant Kalsi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
ttl
expiry
dictionary
expiring
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# py-ttl-dict
Python Dictionary that supports expiring keys.
## Usage
```Python
import ttldict
import time
my_dict = ttldict.TTLDict()
my_dict.set("key", "value," 2) # Expire Key after 2 seconds
print(my_dict.get("key")) # Prints "value"
time.sleep(3)
print(my_dict.get("key")) # Prints "None"
```
## Install
```Bash
$ pip install py-ttl-dict
```
## Additional Usage
### Convert to a Python Dict
```Python
import ttldict
import time
my_dict = ttldict.TTLDict()
my_dict.set("key", "value," 10)
python_dict = my_dict.as_dict()
print(python_dict)
```
## Implementation Details
This implementation maintains a `map` of KV-pairs as well as a `heap` of expiry times. Insert is `O(logn)`, Update TTL is `O(n)` and all accessors are `O(klogn)` where `k` is the number of entries that must be evicted.
Raw data
{
"_id": null,
"home_page": "",
"name": "pyttldict",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "",
"keywords": "ttl,expiry,dictionary,expiring",
"author": "",
"author_email": "Gurjant Kalsi <me@gurjantkalsi.com>",
"download_url": "",
"platform": null,
"description": "# py-ttl-dict\nPython Dictionary that supports expiring keys.\n\n## Usage\n```Python\nimport ttldict\nimport time\n\nmy_dict = ttldict.TTLDict()\n\nmy_dict.set(\"key\", \"value,\" 2) # Expire Key after 2 seconds\n\nprint(my_dict.get(\"key\")) # Prints \"value\"\n\ntime.sleep(3)\n\nprint(my_dict.get(\"key\")) # Prints \"None\"\n```\n\n## Install\n```Bash\n$ pip install py-ttl-dict\n```\n\n## Additional Usage\n### Convert to a Python Dict\n```Python\nimport ttldict\nimport time\n\nmy_dict = ttldict.TTLDict()\n\nmy_dict.set(\"key\", \"value,\" 10)\n\npython_dict = my_dict.as_dict()\n\nprint(python_dict)\n```\n\n## Implementation Details\nThis implementation maintains a `map` of KV-pairs as well as a `heap` of expiry times. Insert is `O(logn)`, Update TTL is `O(n)` and all accessors are `O(klogn)` where `k` is the number of entries that must be evicted.\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 Gurjant Kalsi Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Python Dictionary with timed expiring keys",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/gkalsi/ttl-dict"
},
"split_keywords": [
"ttl",
"expiry",
"dictionary",
"expiring"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f217fe532bb6bed01ba2ae3542d90545fde9197af658b99c38672dc5972983e6",
"md5": "09e46b97286b1646f8b5439f6b466b18",
"sha256": "10cf8626f6696ed489249fc0dc05e05246559ceca02fd2bae67c6fe799714333"
},
"downloads": -1,
"filename": "pyttldict-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "09e46b97286b1646f8b5439f6b466b18",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 4244,
"upload_time": "2024-02-15T08:24:58",
"upload_time_iso_8601": "2024-02-15T08:24:58.242377Z",
"url": "https://files.pythonhosted.org/packages/f2/17/fe532bb6bed01ba2ae3542d90545fde9197af658b99c38672dc5972983e6/pyttldict-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-15 08:24:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gkalsi",
"github_project": "ttl-dict",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pyttldict"
}