一种具有选择性再分配哨兵支持的再分配伺服器的Django admin接口

django-redis-admin的Python项目详细描述


简介

使用django redis admin,您可以查看(并在将来编辑)您的redis 数据库。它支持简单的服务器、主从设置和哨兵设置。

管理员通过创建一个仿造django模型和 querysets使modeladmin认为它使用的是常规的数据库支持模型。

由于Redis只支持基本类型,库允许可选的base64 编码/解码和json编码/解码。

但我不建议将其用作访问Redis的常规queryset在 除了查询数据外,它还执行一些通常不执行的额外查询 需要(例如获取空闲数据)并执行一些自动转换步骤

要求

  • python3.6及以上
  • django(用2.1测试过,可能适用于任何支持 Python3)
  • python redis(pip安装redis

安装

django redis admin可以通过PIP安装。

pip install django-redis-admin

然后只需将redis管理员添加到安装的应用程序中

如果有多个和/或非标准服务器,也可以配置服务器 (即非本地主机)redis服务器

下面是几个配置示例。默认设置始终可以是 可在redis_admin/settings.py中找到

您可以使用以下命令运行演示项目:

cd test_redis_admin
python manage.py runserver

默认用户名/密码是admin/adminhttp://localhost:8080/admin/

基本配置

# https://redis-py.readthedocs.io/en/latest/index.html#redis.RedisREDIS_SERVERS=dict(localhost=dict(),)

显式配置

# https://redis-py.readthedocs.io/en/latest/index.html#redis.RedisREDIS_SERVERS=dict(redis_server_a=dict(host='127.0.0.1',port=6379,db=0),)

主从配置

# https://redis-py.readthedocs.io/en/latest/index.html#redis.RedisREDIS_SERVERS=dict(redis_server_a=dict(master=dict(host='master_hostname',port=6379,db=0),slave=dict(host='slave_hostname',port=6379,db=0),))

哨兵配置

# The `REDIS_SENTINELS` setting should be a list containing host/port# combinations. As documented here:# https://github.com/andymccurdy/redis-py/blob/master/README.rst#sentinel-supportREDIS_SENTINELS=[('server_a',26379),('server_b',26379)]# The `REDIS_SENTINEL_OPTIONS` are the extra arguments to# `redis.sentinel.Sentinel`:# https://github.com/andymccurdy/redis-py/blob/cdfe2befbe00db4a3c48c9ddd6d64dea15f6f0db/redis/sentinel.py#L128-L155REDIS_SENTINEL_OPTIONS=dict(socket_timeout=0.1)# The `service_name` is used to find the server within the Sentinel# configuration. The dictionary key will be used as the name in the admin# https://redis-py.readthedocs.io/en/latest/index.html#redis.RedisREDIS_SERVERS=dict(name_in_admin=dict(service_name='name_in_sentinel'),other_server=dict(service_name='other_server'),)

base64和/或json解码

作为一个方便的选项,所有值都可以选择base64和/或json 编码的。要配置它,可以指定一个正则表达式 与钥匙匹配。

# For all keysREDIS_JSON_KEY_RE='.*'REDIS_BASE64_KEY_RE='.*'# Keys starting with a pattern:REDIS_BASE64_KEY_RE='^some_prefix.*'# Keys ending with a pattern:REDIS_JSON_KEY_RE='.*some_suffix$'

如果需要特定的json解码器,则可以指定json模块。 模块需要是可导入的,并且有一个dumpsloads方法。由 默认情况下,它只是导入json模块:

REDIS_JSON_MODULE='json'

表示裁剪

在django管理列表视图中,默认情况下会裁剪这些值,以防止出现真正的长行。此尺寸可通过以下方式调整:

REDIS_REPR_CROP_SIZE=150

待办事项

  • 允许保存值
  • 允许删除值
  • 支持redis位图
  • 支持redis超日志

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在构造函数外部添加鼠标侦听器   java如何使用比较器对列表进行排序以正确排序空值?   javajavax。由于javax,邮件“535.7.3身份验证失败”。邮件升级(v1.3.1至v1.5.2)   java将arraylist流到固定的二维数组中并打印?   RecyclerView适配器上的java上下文   java如何为此Twitter API为KafkaProducer建立连接   java Spring安全性重写WebSecurity配置适配器的配置(AuthenticationManagerBuilder)是否会影响全局应用程序?   线程“awteventque0”NullPointerException中的java异常   if条件中的null值和null指针异常java   java树集<Object>允许相同类型的多个对象   java定义类;我认不出   字符串java replaceAll()   JAVAutil。scanner(Java)读取文件时如何跳过空格?   java在swing中关闭flash屏幕   java在Wildfly 16中的应用程序中加载pk12文件   有没有工具可以自动生成屏幕抓取的Java代码   创建意图时,java方法getParcelableExtra()返回null   将数据从java传递到jsp   java Android Studio |永久保存布局