from vibora import Vibora
from vibora.blueprints import Blueprint
from vibora.hooks import Events
from aioredis import ConnectionsPool
from config import Config
async def home(pool: ConnectionsPool):
await pool.set('my_key', 'any_value')
value = await pool.get('my_key')
return Response(value.encode())
@api.handle(Events.BEFORE_SERVER_START)
async def initialize_db(app: Vibora, config: Config):
# Creating a pool of connection to Redis.
pool = await aioredis.create_pool(config.redis_host)
# In this case we are registering the pool as a new component
# but if you find yourself using too many components
# feel free to wrap them all inside a single component
# so you don't need to repeat yourself in every route.