gomdoricake.hashnode.devRedis (redis-py)Initialize Make sure you have Redis Open Source or another Redis server. Also install the redis-py client library. import redis from redis.commands.json.path import Path import redis.commands.search.aggregation as aggregations import redis.commands.s...Jan 25·5 min read
gomdoricake.hashnode.devCoroutinesNormal functions are like single-focus tasks. Coroutines allow for multitasking by alternating between different activities. async def coroutine_multiply_be_two(number: int) -> int: return nubmer * 2 def multiply_by_two(number: int) -> int: ...Jan 21·2 min read
gomdoricake.hashnode.devAsyncioAsync I/O is a single-threaded, single-process technique that uses cooperative multitasking. Coroutines are not inherently concurrent. Async I/O is a model of concurrent programming, but it’s not parallelism. It’s more aligned with threading than wit...Jan 21·12 min read
gomdoricake.hashnode.devCode Interview 1 - Redis Cacheimport asyncio import aioredis import pickle # Async cache decorator using Redis redis = aioredis.from_url("redis://localhost") def cache(ttl=60): def deco(func): async def wrapper(*args, **kwargs): key = func.name + ":" + str(args) da...Jan 21·2 min read
gomdoricake.hashnode.devLeetCode 11. Container With Most WaterBrainstorming Thinking Process I thought it could be very easy to solve. You can simply pick one line and the other, multiply them and see if it’s the longest, and repeat this process until you try all the cases that could be made. But here is the th...Jan 20·4 min read