Files
Wu Clan f21006000a Update user role interface to standalone (#177)
* Update user role interface to standalone

* Fix the userinfo schema department field type

* fix update userinfo values

* fix update user avatar value

* update readme docs

* update test data sql

* update readme typo

* update readme docs
2023-07-14 17:01:47 +08:00

34 lines
1.1 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from backend.app.common.redis import redis_client
from backend.app.utils.server_info import server_info
class RedisInfo:
@staticmethod
async def get_info():
info = await redis_client.info()
fmt_info = {}
for key, value in info.items():
if isinstance(value, dict):
value = ','.join({f'{k}={v}' for k, v in value.items()})
else:
value = str(value)
fmt_info[key] = value
db_size = await redis_client.dbsize()
fmt_info.update({'keys_num': db_size})
fmt_uptime = server_info.fmt_seconds(fmt_info.get('uptime_in_seconds', 0))
fmt_info.update({'uptime_in_seconds': fmt_uptime})
return fmt_info
@staticmethod
async def get_stats():
stats_list = []
command_stats = await redis_client.info('commandstats')
for k, v in command_stats.items():
stats_list.append({'name': k.split('_')[-1], 'value': str(v.get('calls', ''))})
return stats_list
redis_info = RedisInfo()