MIT License

项目介绍

alisaifee/coredis 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,采用 MIT License 许可证,目前获得 117 个 Star、22 次 Fork。

仓库全名
alisaifee/coredis
开源许可证
MIT License
Star 数
117
Fork 数
22
未关闭 Issue
10

README 摘要

coredis Fast, async, fully-typed Redis client with support for cluster and sentinel Features Fully typed, even when using pipelines, Lua scripts, and libraries Redis Cluster and Sentinel support Built with structured concurrency on anyio, supports both asyncio and trio Smart command routing: multiplexing when possible, pooling otherwise Server-assisted client-side caching implementation Redis Stack modules support…

完整内容见 GitHub 原始 README 或本页 。

常见问题

coredis 用什么语言开发?

主要使用 Python 编写,采用 MIT License 许可证,目前有 117 个 Star。

coredis 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 coredis 的源码?

可以直接克隆仓库:git clone https://github.com/alisaifee/coredis.git,默认分支为 master;安装与运行步骤见仓库 README。

coredis 最近还在维护吗?

仓库最近一次更新为 9月12日,当前有 10 个未关闭 Issue;Star 数为 117,可作为社区活跃度的参考。

关于

coredis is an async redis client for python with support for redis cluster, sentinel and popular redis modules

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
164
价值分
76
活跃状态
活跃

语言占比

Lua
Makefile
Python
Shell

Release

README

docs codecov Latest Version in PyPI ci Supported Python versions

coredis

Fast, async, fully-typed Redis client with support for cluster and sentinel

Features

Installation

$ pip install coredis

Optional extras

For OpenTelemetry support

$ pip install "coredis[otel]"

To install any dependencies required by the recipes

$ pip install "coredis[recipes]"

Getting started

Single node or cluster

import anyio
import coredis

async def main() -> None:
    client = coredis.Redis(host='127.0.0.1', port=6379, db=0, decode_responses=True)
    # or cluster
    # client = coredis.RedisCluster(startup_nodes=[coredis.connection.TCPLocation("127.0.0.1", 6379)], decode_responses=True)
    async with client:
        await client.flushdb()

        await client.set("foo", 1)
        assert await client.exists(["foo"]) == 1
        assert await client.incr("foo") == 2
        assert await client.expire("foo", 1)
        await anyio.sleep(0.1)
        assert await client.ttl("foo") == 1
        await anyio.sleep(1)
        assert not await client.exists(["foo"])

        async with client.pipeline() as pipeline:
            pipeline.incr("foo")
            value = pipeline.get("foo")
            pipeline.delete(["foo"])

        assert await value == "1"

anyio.run(main, backend="asyncio") # or trio

Sentinel

import anyio
import coredis

async def main() -> None:
    sentinel = coredis.Sentinel(sentinels=[("localhost", 26379)])
    async with sentinel:
        primary: coredis.Redis  = sentinel.primary_for("myservice")
        replica: coredis.Redis  = sentinel.replica_for("myservice")

        async with primary, replica:
            assert await primary.set("fubar", 1)
            assert int(await replica.get("fubar")) == 1

anyio.run(main, backend="asyncio") # or trio

Compatibility

To see a full list of supported Redis commands refer to the Command compatibility documentation. Details about supported Redis modules and their commands can be found here.

coredis is tested against redis versions >= 7.0 The test matrix status can be reviewed here

coredis is additionally tested against:

  • uvloop >= 0.15.0
  • trio

Supported python versions

  • 3.10
  • 3.11
  • 3.12
  • 3.13
  • 3.14
  • PyPy 3.11

Redis API compatible databases

coredis is known to work with the following databases that have redis protocol compatibility:

References

评论

暂无评论