redipy


Nameredipy JSON
Version 0.7.1 PyPI version JSON
download
home_pageNone
Summaryredipy is a uniform interface to Redis-like storage systems. It allows you to use the same Redis API with different backends that implement the same functionality.
upload_time2024-06-27 18:40:19
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseApache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
keywords redis in-memory uniform api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # RediPy

`redipy` is a Python library that provides a uniform interface to Redis-like
storage systems. It allows you to use the same Redis API with different backends
that implement the same functionality, such as:

- `redipy.memory`: A backend that runs inside the current process and stores
  data in memory using Python data structures.
- `redipy.redis`: A backend that connects to an actual Redis instance and
  delegates all operations to it.

[![redipy logo][logo-small]][logo]

## Overview<a id="toc"></a>

<details><summary>Table of Contents</summary>

1. [Installation](#installation)
2. [Usage](#usage)
3. [Features](#features)
4. [Custom Scripts](#custom-scripts)
   * [Simple Example](#simple-example)
   * [Advanced Example](#advanced-example)
5. [Limitations](#limitations)
6. [Contributing](#contributing)
   * [If You Find a Bug](#if-you-find-a-bug)
   * [Missing Redis or Lua Functions](#missing-redis-or-lua-functions)
   * [Implementing New Redis Functions](#implementing-new-redis-functions)
7. [Changelog](#changelog)
8. [License](#license)
9. [Feedback](#feedback)

</details>

This [medium article][medium] explores some of the rationale behind the library.

If you need certain functionality or found a bug, have a look at the
[contributing](#contributing) section.

## Installation<a id="installation"></a>
You can install `redipy` using pip:

```sh
pip install redipy
```

[🔝](#toc)

## Usage<a id="usage"></a>
To use `redipy`, you need to import the library and create a `redipy` client
object with the desired backend. For example:

```python
# Import the redipy library
import redipy

# Create a redipy client using the memory backend
r = redipy.Redis()

# Create a redipy client using the redis backend
r = redipy.Redis(host="localhost", port=6379)

# Or preferred
r = redipy.Redis(
    cfg={
        "host": "localhost",
        "port": 6379,
        "passwd": "",
        # A prefix that gets added to every key.
        # Can be used to implement namespaces.
        "prefix": "",
    })

# You can specify the backend explicitly to ensure that the correct parameters
# are passed to the constructor
r = redipy.Redis(
    backend="redis",
    cfg={
        "host": "localhost",
        "port": 6379,
        "passwd": "",
        "prefix": "",
    })
```

The `redipy` client object supports similar methods and attributes to the
official [Redis][redis] Python client library.
You can use them as you would normally do with `redis`. For example:

```python
# Set some values
r.set_value("foo", "bar")
r.set_value("baz", "qux")

# Get some values
r.get_value("foo")  # "bar"
r.get_value("baz")  # "qux"

# Push some values
r.lpush("mylist", "a", "b", "c")
r.rpush("mylist", "d")

# Pop values
r.lpop("mylist")  # "c"
r.rpop("mylist", 3)  # ["d", "a", "b"]
```

More examples can be found in the [examples folder][examples].

[🔝](#toc)

## Features<a id="features"></a>
The main features of `redipy` are:

- Flexibility: You can choose from different backends that suit your needs and
  preferences, without changing your code or learning new APIs.

- Adaptability: You can start your project small with the memory backend and
  only switch to a full Redis server once the application grows.

- Scripting: You can create backend independent Redis scripts without using Lua.
  Scripts are written using a symbolic API in python.

- Compatibility: You can use any Redis client or tool with any backend.

- Mockability: You can use redipy in tests that require Redis with the memory
  backend to easily mock the functionality without actually having to run a
  Redis server in the background. Also, this avoids issues that might occur
  when running tests in parallel with an actual Redis server.

- Performance: You can leverage the high performance of Redis or other backends
  that offer fast and scalable data storage and retrieval.

- Migration: You can easily migrate data between different backends, or use
  multiple backends simultaneously.

[🔝](#toc)

## Custom Scripts<a id="custom-scripts"></a>

Redis scripts can be defined via a symbolic API in python and can be executed
by any backend.

[🔝](#toc)

### Simple Example<a id="simple-example"></a>

Here, we are writing a filter function that drains a Redis list
and puts items into a "left" and a "right" list by comparing each items
numerical value with a given `cmp` value:

```python
import redipy

# set up script
ctx = redipy.script.FnContext()
# add argument
cmp = ctx.add_arg("cmp")
# add key arguments
inp = redipy.script.RedisList(ctx.add_key("inp"))
left = redipy.script.RedisList(ctx.add_key("left"))
right = redipy.script.RedisList(ctx.add_key("right"))

# add local variable which contains the current value pop'ed from the list
cur = ctx.add_local(inp.lpop())
# we consume "inp" until it is empty
loop = ctx.while_(cur.ne_(None))
# push the value to the list depending on whether it is smaller than `cmp`
b_then, b_else = loop.if_(redipy.script.ToNum(cur).lt_(cmp))
b_then.add(left.rpush(cur))
b_else.add(right.rpush(cur))
# pop next value and store in local variable
loop.add(cur.assign(inp.lpop()))
# the script doesn't return a value
ctx.set_return_value(None)

# make sure to build the script only once and reuse the filter_list function
filter_list = r.register_script(ctx)

r.rpush("mylist", "1", "3", "2", "4")
filter_list(
    keys={
        "inp": "mylist",
        "left": "small",
        "right": "big",
    },
    args={
        "cmp": 3,
    })

r.lpop("mylist", 4)  # []
r.lpop("small", 4)  # ["1", "2"]
r.lpop("big", 4)  # ["3", "4"]
```

[🔝](#toc)

### Advanced Example<a id="advanced-example"></a>

Here, we are implementing and object stack with fall-through lookup. Each frame
in the stack has its own fields. If the user tries to access a field that
doesn't exist in the current stack frame (and they are using `get_cascading`)
the accessor will recursively go down the stack until a value for the given
field is found (or the end of the stack is reached).

```python
from typing import cast
from redipy import RedisClientAPI
from redipy.script import (
    ExecFunction,
    FnContext,
    JSONType,
    RedisHash,
    RedisVar,
    Strs,
    ToIntStr,
    ToNum,
)


class RStack:
    """An example class that simulates a key value stack."""
    def __init__(self, rt: RedisClientAPI) -> None:
        self._rt = rt

        self._set_value = self._set_value_script()
        self._get_value = self._get_value_script()
        self._pop_frame = self._pop_frame_script()
        self._get_cascading = self._get_cascading_script()

    def key(self, base: str, name: str) -> str:
        """
        Compute the key.

        Args:
            base (str): The base key.

            name (str): The name.

        Returns:
            str: The key associated with the name.
        """
        return f"{base}:{name}"

    def push_frame(self, base: str) -> None:
        """
        Pushes a new stack frame.

        Args:
            base (str): The base key.
        """
        self._rt.incrby(self.key(base, "size"), 1)

    def pop_frame(self, base: str) -> dict[str, str]:
        """
        Pops the current stack frame and returns its values.

        Args:
            base (str): The base key.

        Returns:
            dict[str, str] | None: The content of the stack frame.
        """
        res = self._pop_frame(
            keys={
                "size": self.key(base, "size"),
                "frame": self.key(base, "frame"),
            },
            args={})
        if res is None:
            return {}
        return cast(dict, res)

    def set_value(self, base: str, field: str, value: str) -> None:
        """
        Set a value in the current stack frame.

        Args:
            base (str): The base key.

            field (str): The field.

            value (str): The value.
        """
        self._set_value(
            keys={
                "size": self.key(base, "size"),
                "frame": self.key(base, "frame"),
            },
            args={"field": field, "value": value})

    def get_value(self, base: str, field: str) -> JSONType:
        """
        Returns a value from the current stack frame.

        Args:
            base (str): The base key.

            field (str): The field.

        Returns:
            JSONType: The value.
        """
        return self._get_value(
            keys={
                "size": self.key(base, "size"),
                "frame": self.key(base, "frame"),
            },
            args={"field": field})

    def get_cascading(self, base: str, field: str) -> JSONType:
        """
        Returns a value from the stack. If the value is not in the current
        stack frame the value is recursively retrieved from the previous
        stack frames.

        Args:
            base (str): The base key.

            field (str): The field.

        Returns:
            JSONType: The value.
        """
        return self._get_cascading(
            keys={
                "size": self.key(base, "size"),
                "frame": self.key(base, "frame"),
            },
            args={"field": field})

    def _set_value_script(self) -> ExecFunction:
        ctx = FnContext()
        rsize = RedisVar(ctx.add_key("size"))
        rframe = RedisHash(Strs(
            ctx.add_key("frame"),
            ":",
            ToIntStr(rsize.get_value(default=0))))
        field = ctx.add_arg("field")
        value = ctx.add_arg("value")
        ctx.add(rframe.hset({
            field: value,
        }))
        ctx.set_return_value(None)
        return self._rt.register_script(ctx)

    def _get_value_script(self) -> ExecFunction:
        ctx = FnContext()
        rsize = RedisVar(ctx.add_key("size"))
        rframe = RedisHash(Strs(
            ctx.add_key("frame"),
            ":",
            ToIntStr(rsize.get_value(default=0))))
        field = ctx.add_arg("field")
        ctx.set_return_value(rframe.hget(field))
        return self._rt.register_script(ctx)

    def _pop_frame_script(self) -> ExecFunction:
        ctx = FnContext()
        rsize = RedisVar(ctx.add_key("size"))
        rframe = RedisHash(Strs(
            ctx.add_key("frame"),
            ":",
            ToIntStr(rsize.get_value(default=0))))
        lcl = ctx.add_local(rframe.hgetall())
        ctx.add(rframe.delete())

        b_then, b_else = ctx.if_(ToNum(rsize.get_value(default=0)).gt_(0))
        b_then.add(rsize.incrby(-1))
        b_else.add(rsize.delete())

        ctx.set_return_value(lcl)
        return self._rt.register_script(ctx)

    def _get_cascading_script(self) -> ExecFunction:
        ctx = FnContext()
        rsize = RedisVar(ctx.add_key("size"))
        base = ctx.add_local(ctx.add_key("frame"))
        field = ctx.add_arg("field")
        pos = ctx.add_local(ToNum(rsize.get_value(default=0)))
        res = ctx.add_local(None)
        cur = ctx.add_local(None)
        rframe = RedisHash(cur)

        loop = ctx.while_(res.eq_(None).and_(pos.ge_(0)))
        loop.add(cur.assign(Strs(base, ":", ToIntStr(pos))))
        loop.add(res.assign(rframe.hget(field)))
        loop.add(pos.assign(pos - 1))

        ctx.set_return_value(res)
        return self._rt.register_script(ctx)
```

[🔝](#toc)

## Limitations<a id="limitations"></a>
The current limitations of `redipy` are:

- Some Redis commands are not supported yet: This is likely due to redundant
  functionality. For all other cases it will eventually be resolved.
  Check [this issue to see the status of redis functions][implemented].
- The API differs slightly: Most notably stored values are always strings
  (i.e., the bytes returned by Redis are decoded as utf-8).
- The semantic of Redis functions inside scripts has been altered to feel more
  natural coming from python: Redis functions inside Lua scripts often differ
  greatly from the documented behavior. For example, `LPOP` returns `false` for
  an empty list inside Lua (instead of `nil` or `cjson.null`). While `LPOP`
  returns `None` in the python API. The script API of `redipy` has been altered
  to match the python API more closely. As the user doesn't code in Lua directly
  the benefit of having a more consistent API outweighs the more complicated Lua
  code that needs to be generated in the backend.
- Scripts aim to use python semantics as best as possible: In Lua array indices
  start at 1. The script API uses a 0 based indexing system and transparently
  adjusts indices in the Lua backend. Other, similar changes are performed
  as well.
- Scripts use JSON to pass arguments and return values: The arguments to the
  script are passed as JSON bytes for the Lua backend. Keys are passed as is.
  The return value of the script is also converted into JSON when moving from
  Lua to python. Note, that the empty dictionary (`{}`) and the empty list
  (`[]`) are indistinguishable in Lua so `None` is returned instead of setting
  the return value to either of these.

[🔝](#toc)

## Contributing<a id="contributing"></a>

Any contribution, even if it is just creating an issue for a bug,
is much appreciated.

[🔝](#toc)

### If You Find a Bug<a id="if-you-find-a-bug"></a>

If you encounter a bug, please open an issue to draw attention to it or give
a thumbsup if the issue already exists. This helps with prioritizing
implementation efforts. Even if you cannot solve the bug yourself,
investigating why it happens or creating a PR to add test cases helps a lot.
If you have a fix for a bug don't hesistate to open a PR.

[🔝](#toc)

### Missing Redis or Lua Functions<a id="missing-redis-or-lua-functions"></a>
If you encounter a missing Redis or Lua function please consider adding it
yourself (see the [implementing](#implementing-new-redis-functions) section).
Here also opening an issue or giving a thumbsup to existing issues helps
with prioritization.

However, if you need it only in your local setup
without API support or support for multiple backends, pipelines, etc. you can
use the raw underlying Redis connection via
`redipy.main.Redis.get_redis_runtime` and
`redipy.redis.conn.RedisConnection.get_connection` or make use of
the plug-in mechanism.

For the memory backend you can use
`redipy.memory.rt.LocalRuntime.add_redis_function_plugin` or
`redipy.memory.rt.LocalRuntime.add_general_function_plugin`. The methods need
a module that contains subclasses of `redipy.plugin.LocalRedisFunction` and
`redipy.plugin.LocalGeneralFunction` respectively. Once the new functions are
defined via loading the plugin they can be used in a `redipy.script.FnContext`
via `redipy.script.RedisFn` or `redipy.script.CallFn` respectively.

Note, that `redipy.script.RedisFn` and `redipy.script.CallFn` can always be
used in Redis backend scripts. However, calling functions this way will have
the native Lua behavior which can lead to surprising results. To patch those
up as well you can use `redipy.redis.lua.LuaBackend.add_redis_patch_plugin`,
`redipy.redis.lua.LuaBackend.add_general_patch_plugin`, and
`redipy.redis.lua.LuaBackend.add_helper_function_plugin` to add the subclasses
of `redipy.plugin.LuaRedisPatch`, `redipy.plugin.LuaRedisPatch`, and
`redipy.plugin.HelperFunction` respectively. Those functions then can also be
used with the `redipy.script.RedisFn` and `redipy.script.CallFn` commands.

Adding functions as described above is discouraged as it may lead to
inconsistent support of different backends and inconsistent behavior across
different backends.

[🔝](#toc)

### Implementing New Redis Functions<a id="implementing-new-redis-functions"></a>

The easiest way to contribute to `redipy` is to pick some Redis API functions
that have not (or not completely) been [implemented][implemented] in `redipy`
yet. It is also much appreciated if you just add test cases or the stubs in a
PR. For a full implementation follow these steps:

1. Add the signature of the function to `redipy.api.RedisAPI`. Adjust as
  necessary from the Redis spec to get a pythonic feel. Also, add the signature
  to `redipy.api.PipelineAPI` but with `None` as return value. Additionally,
  add the redirect to the backend in `redipy.main.Redis`.
2. Implement the function in `redipy.redis.conn.RedisConnection` and
  `redipy.redis.conn.PipelineConnection`. This should
  be straightforward as there are not too many changes expected. Don't forget
  to convert bytes into strings via `...decode("utf-8")` (there are various
  helper functions for this in `redipy.util`).
3. Add tests to `test/test_sanity.py` to determine the function's behavior in
  Lua (especially its edge cases).
4. If the Lua behavior needs to be changed to provide a better feel you can add
  a monkeypatch for the function call by either creating a class in
  `redipy.redis.rpatch` to directly change the returned expr for the execution
  graph or using a Lua helper function via adding a class to
  `redipy.redis.helpers` (you need to use a patch to use the helper in the
  right location).
5. Next, add and implement the functionality in
  `redipy.memory.state.Machine` and add the appropriate redirects in
  `redipy.memory.rt.LocalRuntime` and `redipy.memory.rt.LocalPipeline`.
6. To make the new function accessible in scripts from the memory backend add
  a class in `redipy.memory.rfun`.
7. Add the approriate class or method in the right `redipy.symbolic.r...py`
  file. If it is a new class / file add an import to `redipy.script`.
8. Add a new test in `test/test_api.py` to verify the new function works inside
  a script for all backends. You can run `make pytest FILE=test/test_api.py`
  to execute the test and `make coverage-report` to verify that the new code
  is executed.
9. Make sure `make lint-all` passes, as well as, all tests (`make pytest`)
  run without issue.

You can submit your patch as pull request [here][pulls].

[🔝](#toc)

## Changelog<a id="changelog"></a>
The changelog can be found [here][changelog].

[🔝](#toc)

## License<a id="license"></a>
`redipy` is licensed under the [Apache License (Version 2.0)][license].

[🔝](#toc)

## Feedback<a id="feedback"></a>
If you have any questions, suggestions, or issues with `redipy`, please feel
free to [open an issue][issues] on GitHub. I would love to hear your feedback
and improve `redipy`. Thank you!

[🔝](#toc)

[changelog]: https://github.com/JosuaKrause/redipy/blob/main/CHANGELOG.md
[examples]: https://github.com/JosuaKrause/redipy/tree/main/examples
[implemented]: https://github.com/JosuaKrause/redipy/issues/8
[issues]: https://github.com/JosuaKrause/redipy/issues
[license]: https://github.com/JosuaKrause/redipy/blob/v0.4.2/LICENSE
[logo-small]: https://raw.githubusercontent.com/JosuaKrause/redipy/v0.4.2/img/redipy_logo_small.png
[logo]: https://raw.githubusercontent.com/JosuaKrause/redipy/v0.4.2/img/redipy_logo.png
[medium]: https://medium.josuakrause.com/a-backend-agnostic-redis-interface-9fdeb8641bc5?source=friends_link&sk=565113f29f4cfadf174aa3ab23ab9a16
[pulls]: https://github.com/JosuaKrause/redipy/pulls
[redis]: https://pypi.org/project/redis/

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "redipy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "redis, in-memory, uniform api",
    "author": null,
    "author_email": "Josua Krause <josua.krause@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/66/89/489eab563fca89f7e9b5192759339166092b940059aeac858d9a3f9d92a2/redipy-0.7.1.tar.gz",
    "platform": null,
    "description": "# RediPy\n\n`redipy` is a Python library that provides a uniform interface to Redis-like\nstorage systems. It allows you to use the same Redis API with different backends\nthat implement the same functionality, such as:\n\n- `redipy.memory`: A backend that runs inside the current process and stores\n  data in memory using Python data structures.\n- `redipy.redis`: A backend that connects to an actual Redis instance and\n  delegates all operations to it.\n\n[![redipy logo][logo-small]][logo]\n\n## Overview<a id=\"toc\"></a>\n\n<details><summary>Table of Contents</summary>\n\n1. [Installation](#installation)\n2. [Usage](#usage)\n3. [Features](#features)\n4. [Custom Scripts](#custom-scripts)\n   * [Simple Example](#simple-example)\n   * [Advanced Example](#advanced-example)\n5. [Limitations](#limitations)\n6. [Contributing](#contributing)\n   * [If You Find a Bug](#if-you-find-a-bug)\n   * [Missing Redis or Lua Functions](#missing-redis-or-lua-functions)\n   * [Implementing New Redis Functions](#implementing-new-redis-functions)\n7. [Changelog](#changelog)\n8. [License](#license)\n9. [Feedback](#feedback)\n\n</details>\n\nThis [medium article][medium] explores some of the rationale behind the library.\n\nIf you need certain functionality or found a bug, have a look at the\n[contributing](#contributing) section.\n\n## Installation<a id=\"installation\"></a>\nYou can install `redipy` using pip:\n\n```sh\npip install redipy\n```\n\n[\ud83d\udd1d](#toc)\n\n## Usage<a id=\"usage\"></a>\nTo use `redipy`, you need to import the library and create a `redipy` client\nobject with the desired backend. For example:\n\n```python\n# Import the redipy library\nimport redipy\n\n# Create a redipy client using the memory backend\nr = redipy.Redis()\n\n# Create a redipy client using the redis backend\nr = redipy.Redis(host=\"localhost\", port=6379)\n\n# Or preferred\nr = redipy.Redis(\n    cfg={\n        \"host\": \"localhost\",\n        \"port\": 6379,\n        \"passwd\": \"\",\n        # A prefix that gets added to every key.\n        # Can be used to implement namespaces.\n        \"prefix\": \"\",\n    })\n\n# You can specify the backend explicitly to ensure that the correct parameters\n# are passed to the constructor\nr = redipy.Redis(\n    backend=\"redis\",\n    cfg={\n        \"host\": \"localhost\",\n        \"port\": 6379,\n        \"passwd\": \"\",\n        \"prefix\": \"\",\n    })\n```\n\nThe `redipy` client object supports similar methods and attributes to the\nofficial [Redis][redis] Python client library.\nYou can use them as you would normally do with `redis`. For example:\n\n```python\n# Set some values\nr.set_value(\"foo\", \"bar\")\nr.set_value(\"baz\", \"qux\")\n\n# Get some values\nr.get_value(\"foo\")  # \"bar\"\nr.get_value(\"baz\")  # \"qux\"\n\n# Push some values\nr.lpush(\"mylist\", \"a\", \"b\", \"c\")\nr.rpush(\"mylist\", \"d\")\n\n# Pop values\nr.lpop(\"mylist\")  # \"c\"\nr.rpop(\"mylist\", 3)  # [\"d\", \"a\", \"b\"]\n```\n\nMore examples can be found in the [examples folder][examples].\n\n[\ud83d\udd1d](#toc)\n\n## Features<a id=\"features\"></a>\nThe main features of `redipy` are:\n\n- Flexibility: You can choose from different backends that suit your needs and\n  preferences, without changing your code or learning new APIs.\n\n- Adaptability: You can start your project small with the memory backend and\n  only switch to a full Redis server once the application grows.\n\n- Scripting: You can create backend independent Redis scripts without using Lua.\n  Scripts are written using a symbolic API in python.\n\n- Compatibility: You can use any Redis client or tool with any backend.\n\n- Mockability: You can use redipy in tests that require Redis with the memory\n  backend to easily mock the functionality without actually having to run a\n  Redis server in the background. Also, this avoids issues that might occur\n  when running tests in parallel with an actual Redis server.\n\n- Performance: You can leverage the high performance of Redis or other backends\n  that offer fast and scalable data storage and retrieval.\n\n- Migration: You can easily migrate data between different backends, or use\n  multiple backends simultaneously.\n\n[\ud83d\udd1d](#toc)\n\n## Custom Scripts<a id=\"custom-scripts\"></a>\n\nRedis scripts can be defined via a symbolic API in python and can be executed\nby any backend.\n\n[\ud83d\udd1d](#toc)\n\n### Simple Example<a id=\"simple-example\"></a>\n\nHere, we are writing a filter function that drains a Redis list\nand puts items into a \"left\" and a \"right\" list by comparing each items\nnumerical value with a given `cmp` value:\n\n```python\nimport redipy\n\n# set up script\nctx = redipy.script.FnContext()\n# add argument\ncmp = ctx.add_arg(\"cmp\")\n# add key arguments\ninp = redipy.script.RedisList(ctx.add_key(\"inp\"))\nleft = redipy.script.RedisList(ctx.add_key(\"left\"))\nright = redipy.script.RedisList(ctx.add_key(\"right\"))\n\n# add local variable which contains the current value pop'ed from the list\ncur = ctx.add_local(inp.lpop())\n# we consume \"inp\" until it is empty\nloop = ctx.while_(cur.ne_(None))\n# push the value to the list depending on whether it is smaller than `cmp`\nb_then, b_else = loop.if_(redipy.script.ToNum(cur).lt_(cmp))\nb_then.add(left.rpush(cur))\nb_else.add(right.rpush(cur))\n# pop next value and store in local variable\nloop.add(cur.assign(inp.lpop()))\n# the script doesn't return a value\nctx.set_return_value(None)\n\n# make sure to build the script only once and reuse the filter_list function\nfilter_list = r.register_script(ctx)\n\nr.rpush(\"mylist\", \"1\", \"3\", \"2\", \"4\")\nfilter_list(\n    keys={\n        \"inp\": \"mylist\",\n        \"left\": \"small\",\n        \"right\": \"big\",\n    },\n    args={\n        \"cmp\": 3,\n    })\n\nr.lpop(\"mylist\", 4)  # []\nr.lpop(\"small\", 4)  # [\"1\", \"2\"]\nr.lpop(\"big\", 4)  # [\"3\", \"4\"]\n```\n\n[\ud83d\udd1d](#toc)\n\n### Advanced Example<a id=\"advanced-example\"></a>\n\nHere, we are implementing and object stack with fall-through lookup. Each frame\nin the stack has its own fields. If the user tries to access a field that\ndoesn't exist in the current stack frame (and they are using `get_cascading`)\nthe accessor will recursively go down the stack until a value for the given\nfield is found (or the end of the stack is reached).\n\n```python\nfrom typing import cast\nfrom redipy import RedisClientAPI\nfrom redipy.script import (\n    ExecFunction,\n    FnContext,\n    JSONType,\n    RedisHash,\n    RedisVar,\n    Strs,\n    ToIntStr,\n    ToNum,\n)\n\n\nclass RStack:\n    \"\"\"An example class that simulates a key value stack.\"\"\"\n    def __init__(self, rt: RedisClientAPI) -> None:\n        self._rt = rt\n\n        self._set_value = self._set_value_script()\n        self._get_value = self._get_value_script()\n        self._pop_frame = self._pop_frame_script()\n        self._get_cascading = self._get_cascading_script()\n\n    def key(self, base: str, name: str) -> str:\n        \"\"\"\n        Compute the key.\n\n        Args:\n            base (str): The base key.\n\n            name (str): The name.\n\n        Returns:\n            str: The key associated with the name.\n        \"\"\"\n        return f\"{base}:{name}\"\n\n    def push_frame(self, base: str) -> None:\n        \"\"\"\n        Pushes a new stack frame.\n\n        Args:\n            base (str): The base key.\n        \"\"\"\n        self._rt.incrby(self.key(base, \"size\"), 1)\n\n    def pop_frame(self, base: str) -> dict[str, str]:\n        \"\"\"\n        Pops the current stack frame and returns its values.\n\n        Args:\n            base (str): The base key.\n\n        Returns:\n            dict[str, str] | None: The content of the stack frame.\n        \"\"\"\n        res = self._pop_frame(\n            keys={\n                \"size\": self.key(base, \"size\"),\n                \"frame\": self.key(base, \"frame\"),\n            },\n            args={})\n        if res is None:\n            return {}\n        return cast(dict, res)\n\n    def set_value(self, base: str, field: str, value: str) -> None:\n        \"\"\"\n        Set a value in the current stack frame.\n\n        Args:\n            base (str): The base key.\n\n            field (str): The field.\n\n            value (str): The value.\n        \"\"\"\n        self._set_value(\n            keys={\n                \"size\": self.key(base, \"size\"),\n                \"frame\": self.key(base, \"frame\"),\n            },\n            args={\"field\": field, \"value\": value})\n\n    def get_value(self, base: str, field: str) -> JSONType:\n        \"\"\"\n        Returns a value from the current stack frame.\n\n        Args:\n            base (str): The base key.\n\n            field (str): The field.\n\n        Returns:\n            JSONType: The value.\n        \"\"\"\n        return self._get_value(\n            keys={\n                \"size\": self.key(base, \"size\"),\n                \"frame\": self.key(base, \"frame\"),\n            },\n            args={\"field\": field})\n\n    def get_cascading(self, base: str, field: str) -> JSONType:\n        \"\"\"\n        Returns a value from the stack. If the value is not in the current\n        stack frame the value is recursively retrieved from the previous\n        stack frames.\n\n        Args:\n            base (str): The base key.\n\n            field (str): The field.\n\n        Returns:\n            JSONType: The value.\n        \"\"\"\n        return self._get_cascading(\n            keys={\n                \"size\": self.key(base, \"size\"),\n                \"frame\": self.key(base, \"frame\"),\n            },\n            args={\"field\": field})\n\n    def _set_value_script(self) -> ExecFunction:\n        ctx = FnContext()\n        rsize = RedisVar(ctx.add_key(\"size\"))\n        rframe = RedisHash(Strs(\n            ctx.add_key(\"frame\"),\n            \":\",\n            ToIntStr(rsize.get_value(default=0))))\n        field = ctx.add_arg(\"field\")\n        value = ctx.add_arg(\"value\")\n        ctx.add(rframe.hset({\n            field: value,\n        }))\n        ctx.set_return_value(None)\n        return self._rt.register_script(ctx)\n\n    def _get_value_script(self) -> ExecFunction:\n        ctx = FnContext()\n        rsize = RedisVar(ctx.add_key(\"size\"))\n        rframe = RedisHash(Strs(\n            ctx.add_key(\"frame\"),\n            \":\",\n            ToIntStr(rsize.get_value(default=0))))\n        field = ctx.add_arg(\"field\")\n        ctx.set_return_value(rframe.hget(field))\n        return self._rt.register_script(ctx)\n\n    def _pop_frame_script(self) -> ExecFunction:\n        ctx = FnContext()\n        rsize = RedisVar(ctx.add_key(\"size\"))\n        rframe = RedisHash(Strs(\n            ctx.add_key(\"frame\"),\n            \":\",\n            ToIntStr(rsize.get_value(default=0))))\n        lcl = ctx.add_local(rframe.hgetall())\n        ctx.add(rframe.delete())\n\n        b_then, b_else = ctx.if_(ToNum(rsize.get_value(default=0)).gt_(0))\n        b_then.add(rsize.incrby(-1))\n        b_else.add(rsize.delete())\n\n        ctx.set_return_value(lcl)\n        return self._rt.register_script(ctx)\n\n    def _get_cascading_script(self) -> ExecFunction:\n        ctx = FnContext()\n        rsize = RedisVar(ctx.add_key(\"size\"))\n        base = ctx.add_local(ctx.add_key(\"frame\"))\n        field = ctx.add_arg(\"field\")\n        pos = ctx.add_local(ToNum(rsize.get_value(default=0)))\n        res = ctx.add_local(None)\n        cur = ctx.add_local(None)\n        rframe = RedisHash(cur)\n\n        loop = ctx.while_(res.eq_(None).and_(pos.ge_(0)))\n        loop.add(cur.assign(Strs(base, \":\", ToIntStr(pos))))\n        loop.add(res.assign(rframe.hget(field)))\n        loop.add(pos.assign(pos - 1))\n\n        ctx.set_return_value(res)\n        return self._rt.register_script(ctx)\n```\n\n[\ud83d\udd1d](#toc)\n\n## Limitations<a id=\"limitations\"></a>\nThe current limitations of `redipy` are:\n\n- Some Redis commands are not supported yet: This is likely due to redundant\n  functionality. For all other cases it will eventually be resolved.\n  Check [this issue to see the status of redis functions][implemented].\n- The API differs slightly: Most notably stored values are always strings\n  (i.e., the bytes returned by Redis are decoded as utf-8).\n- The semantic of Redis functions inside scripts has been altered to feel more\n  natural coming from python: Redis functions inside Lua scripts often differ\n  greatly from the documented behavior. For example, `LPOP` returns `false` for\n  an empty list inside Lua (instead of `nil` or `cjson.null`). While `LPOP`\n  returns `None` in the python API. The script API of `redipy` has been altered\n  to match the python API more closely. As the user doesn't code in Lua directly\n  the benefit of having a more consistent API outweighs the more complicated Lua\n  code that needs to be generated in the backend.\n- Scripts aim to use python semantics as best as possible: In Lua array indices\n  start at 1. The script API uses a 0 based indexing system and transparently\n  adjusts indices in the Lua backend. Other, similar changes are performed\n  as well.\n- Scripts use JSON to pass arguments and return values: The arguments to the\n  script are passed as JSON bytes for the Lua backend. Keys are passed as is.\n  The return value of the script is also converted into JSON when moving from\n  Lua to python. Note, that the empty dictionary (`{}`) and the empty list\n  (`[]`) are indistinguishable in Lua so `None` is returned instead of setting\n  the return value to either of these.\n\n[\ud83d\udd1d](#toc)\n\n## Contributing<a id=\"contributing\"></a>\n\nAny contribution, even if it is just creating an issue for a bug,\nis much appreciated.\n\n[\ud83d\udd1d](#toc)\n\n### If You Find a Bug<a id=\"if-you-find-a-bug\"></a>\n\nIf you encounter a bug, please open an issue to draw attention to it or give\na thumbsup if the issue already exists. This helps with prioritizing\nimplementation efforts. Even if you cannot solve the bug yourself,\ninvestigating why it happens or creating a PR to add test cases helps a lot.\nIf you have a fix for a bug don't hesistate to open a PR.\n\n[\ud83d\udd1d](#toc)\n\n### Missing Redis or Lua Functions<a id=\"missing-redis-or-lua-functions\"></a>\nIf you encounter a missing Redis or Lua function please consider adding it\nyourself (see the [implementing](#implementing-new-redis-functions) section).\nHere also opening an issue or giving a thumbsup to existing issues helps\nwith prioritization.\n\nHowever, if you need it only in your local setup\nwithout API support or support for multiple backends, pipelines, etc. you can\nuse the raw underlying Redis connection via\n`redipy.main.Redis.get_redis_runtime` and\n`redipy.redis.conn.RedisConnection.get_connection` or make use of\nthe plug-in mechanism.\n\nFor the memory backend you can use\n`redipy.memory.rt.LocalRuntime.add_redis_function_plugin` or\n`redipy.memory.rt.LocalRuntime.add_general_function_plugin`. The methods need\na module that contains subclasses of `redipy.plugin.LocalRedisFunction` and\n`redipy.plugin.LocalGeneralFunction` respectively. Once the new functions are\ndefined via loading the plugin they can be used in a `redipy.script.FnContext`\nvia `redipy.script.RedisFn` or `redipy.script.CallFn` respectively.\n\nNote, that `redipy.script.RedisFn` and `redipy.script.CallFn` can always be\nused in Redis backend scripts. However, calling functions this way will have\nthe native Lua behavior which can lead to surprising results. To patch those\nup as well you can use `redipy.redis.lua.LuaBackend.add_redis_patch_plugin`,\n`redipy.redis.lua.LuaBackend.add_general_patch_plugin`, and\n`redipy.redis.lua.LuaBackend.add_helper_function_plugin` to add the subclasses\nof `redipy.plugin.LuaRedisPatch`, `redipy.plugin.LuaRedisPatch`, and\n`redipy.plugin.HelperFunction` respectively. Those functions then can also be\nused with the `redipy.script.RedisFn` and `redipy.script.CallFn` commands.\n\nAdding functions as described above is discouraged as it may lead to\ninconsistent support of different backends and inconsistent behavior across\ndifferent backends.\n\n[\ud83d\udd1d](#toc)\n\n### Implementing New Redis Functions<a id=\"implementing-new-redis-functions\"></a>\n\nThe easiest way to contribute to `redipy` is to pick some Redis API functions\nthat have not (or not completely) been [implemented][implemented] in `redipy`\nyet. It is also much appreciated if you just add test cases or the stubs in a\nPR. For a full implementation follow these steps:\n\n1. Add the signature of the function to `redipy.api.RedisAPI`. Adjust as\n  necessary from the Redis spec to get a pythonic feel. Also, add the signature\n  to `redipy.api.PipelineAPI` but with `None` as return value. Additionally,\n  add the redirect to the backend in `redipy.main.Redis`.\n2. Implement the function in `redipy.redis.conn.RedisConnection` and\n  `redipy.redis.conn.PipelineConnection`. This should\n  be straightforward as there are not too many changes expected. Don't forget\n  to convert bytes into strings via `...decode(\"utf-8\")` (there are various\n  helper functions for this in `redipy.util`).\n3. Add tests to `test/test_sanity.py` to determine the function's behavior in\n  Lua (especially its edge cases).\n4. If the Lua behavior needs to be changed to provide a better feel you can add\n  a monkeypatch for the function call by either creating a class in\n  `redipy.redis.rpatch` to directly change the returned expr for the execution\n  graph or using a Lua helper function via adding a class to\n  `redipy.redis.helpers` (you need to use a patch to use the helper in the\n  right location).\n5. Next, add and implement the functionality in\n  `redipy.memory.state.Machine` and add the appropriate redirects in\n  `redipy.memory.rt.LocalRuntime` and `redipy.memory.rt.LocalPipeline`.\n6. To make the new function accessible in scripts from the memory backend add\n  a class in `redipy.memory.rfun`.\n7. Add the approriate class or method in the right `redipy.symbolic.r...py`\n  file. If it is a new class / file add an import to `redipy.script`.\n8. Add a new test in `test/test_api.py` to verify the new function works inside\n  a script for all backends. You can run `make pytest FILE=test/test_api.py`\n  to execute the test and `make coverage-report` to verify that the new code\n  is executed.\n9. Make sure `make lint-all` passes, as well as, all tests (`make pytest`)\n  run without issue.\n\nYou can submit your patch as pull request [here][pulls].\n\n[\ud83d\udd1d](#toc)\n\n## Changelog<a id=\"changelog\"></a>\nThe changelog can be found [here][changelog].\n\n[\ud83d\udd1d](#toc)\n\n## License<a id=\"license\"></a>\n`redipy` is licensed under the [Apache License (Version 2.0)][license].\n\n[\ud83d\udd1d](#toc)\n\n## Feedback<a id=\"feedback\"></a>\nIf you have any questions, suggestions, or issues with `redipy`, please feel\nfree to [open an issue][issues] on GitHub. I would love to hear your feedback\nand improve `redipy`. Thank you!\n\n[\ud83d\udd1d](#toc)\n\n[changelog]: https://github.com/JosuaKrause/redipy/blob/main/CHANGELOG.md\n[examples]: https://github.com/JosuaKrause/redipy/tree/main/examples\n[implemented]: https://github.com/JosuaKrause/redipy/issues/8\n[issues]: https://github.com/JosuaKrause/redipy/issues\n[license]: https://github.com/JosuaKrause/redipy/blob/v0.4.2/LICENSE\n[logo-small]: https://raw.githubusercontent.com/JosuaKrause/redipy/v0.4.2/img/redipy_logo_small.png\n[logo]: https://raw.githubusercontent.com/JosuaKrause/redipy/v0.4.2/img/redipy_logo.png\n[medium]: https://medium.josuakrause.com/a-backend-agnostic-redis-interface-9fdeb8641bc5?source=friends_link&sk=565113f29f4cfadf174aa3ab23ab9a16\n[pulls]: https://github.com/JosuaKrause/redipy/pulls\n[redis]: https://pypi.org/project/redis/\n",
    "bugtrack_url": null,
    "license": "Apache License Version 2.0, January 2004 http://www.apache.org/licenses/  TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION  1. Definitions.  \"License\" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.  \"Licensor\" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.  \"Legal Entity\" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, \"control\" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.  \"You\" (or \"Your\") shall mean an individual or Legal Entity exercising permissions granted by this License.  \"Source\" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.  \"Object\" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.  \"Work\" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).  \"Derivative Works\" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.  \"Contribution\" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, \"submitted\" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as \"Not a Contribution.\"  \"Contributor\" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.  2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.  3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.  4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:  (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and  (b) You must cause any modified files to carry prominent notices stating that You changed the files; and  (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and  (d) If the Work includes a \"NOTICE\" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.  You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.  5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.  6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.  7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.  8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.  9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.  END OF TERMS AND CONDITIONS  APPENDIX: How to apply the Apache License to your work.  To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets \"[]\" replaced with your own identifying information. (Don't include the brackets!)  The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same \"printed page\" as the copyright notice for easier identification within third-party archives.  Copyright [yyyy] [name of copyright owner]  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ",
    "summary": "redipy is a uniform interface to Redis-like storage systems. It allows you to use the same Redis API with different backends that implement the same functionality.",
    "version": "0.7.1",
    "project_urls": {
        "Changelog": "https://github.com/JosuaKrause/redipy/blob/main/CHANGELOG.md",
        "Issues": "https://github.com/JosuaKrause/redipy/issues",
        "Source": "https://github.com/JosuaKrause/redipy"
    },
    "split_keywords": [
        "redis",
        " in-memory",
        " uniform api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2f1840f7d112b3d4e247c9a4fc0942789cce71b6f05c8d7d161c68f621bb7554",
                "md5": "d81e1c5fa2167271ffa49ec167b984f0",
                "sha256": "7167be345712d39101c34366045e51cec5bfbe14dccd382dc33be9a2f2c9dd91"
            },
            "downloads": -1,
            "filename": "redipy-0.7.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d81e1c5fa2167271ffa49ec167b984f0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 107185,
            "upload_time": "2024-06-27T18:40:18",
            "upload_time_iso_8601": "2024-06-27T18:40:18.167157Z",
            "url": "https://files.pythonhosted.org/packages/2f/18/40f7d112b3d4e247c9a4fc0942789cce71b6f05c8d7d161c68f621bb7554/redipy-0.7.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6689489eab563fca89f7e9b5192759339166092b940059aeac858d9a3f9d92a2",
                "md5": "8129da649f61a89082b72eea3082627f",
                "sha256": "3ab8527cdea51d5559fe262b4ad114d0e4ab613c6148e7a43e5c42ab86af503e"
            },
            "downloads": -1,
            "filename": "redipy-0.7.1.tar.gz",
            "has_sig": false,
            "md5_digest": "8129da649f61a89082b72eea3082627f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 113262,
            "upload_time": "2024-06-27T18:40:19",
            "upload_time_iso_8601": "2024-06-27T18:40:19.938005Z",
            "url": "https://files.pythonhosted.org/packages/66/89/489eab563fca89f7e9b5192759339166092b940059aeac858d9a3f9d92a2/redipy-0.7.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-27 18:40:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "JosuaKrause",
    "github_project": "redipy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "redipy"
}
        
Elapsed time: 0.30878s