mirror of
https://github.com/fastapi-practices/fastapi_best_architecture.git
synced 2025-08-15 12:03:28 +08:00

* define the basic architecture * Update script and deployment file locations * Update the route registration * Fix CI download dependencies * Updated ruff to 0.3.3 * Update app subdirectory naming * Update the model import * fix pre-commit pdm lock * Update the service directory naming * Add CRUD method documents * Fix the issue of circular import * Update the README document * Update the SQL statement for create tables * Update docker scripts and documentation * Fix docker scripts * Update the backend README.md * Add the security folder and move the redis client * Update the configuration item * Fix environment configuration reads * Update the default configuration * Updated README description * Updated the user registration API * Fix test cases * Update the celery configuration * Update and fix celery configuration * Updated the celery structure * Update celery tasks and api * Add celery flower * Update the import style * Update contributors
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
from backend.database.db_redis import redis_client
|
|
from backend.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()
|