Example #1
0
    async def delete_rule(_id: str, db: AioRedis):
        """
        Deletes a rate limiter rule.

        @param id: (string) the ID of the rate limiter rule to delete
        @param db: (object) db connection
        """
        await asyncio.gather(
            db.delete(_id),
            RateLimiter._clear_indexes(_id, db),
            db.srem(rules_set, _id)
        )
Example #2
0
    async def delete_entry(_id: str, db: AioRedis):
        """
        Deletes a rate limiter entry.

        @param host: (string) the hostname of the rate limiter entry to delete
        @param db: (object) db connection
        """
        await asyncio.gather(
            db.delete(_id),
            RateLimiter._clear_indexes(_id, db),
            db.srem(entry_set, _id)
        )
Example #3
0
    async def delete(_id: str, db: AioRedis):
        """
        deletes a endpoint cache rule.

        @param id: (string) id of endpoint cache to delete
        @param db: (object) db connection
        """
        await asyncio.gather(
            db.delete(_id),
            EndpointCacher._clear_indexes(_id, db),
            db.srem(endpoint_cache_set, _id),
        )
Example #4
0
    async def clear_empty_entries(db: AioRedis):
        empty_entries = []
        entries_keys = await DB.fetch_members(entry_set, db)
        for key in entries_keys:
            entry = await db.hgetall(key, encoding='utf-8')
            pydash.is_empty(entry) and empty_entries.append(key)

        coroutines = []
        for empty_entry in empty_entries:
            coroutines.append(db.srem(entry_set, empty_entry))
            coroutines.append(RateLimiter._clear_indexes(empty_entry, db))

        await Async.all(coroutines)