LRU cache.

Least Recently Used (LRU) cache. We can describe this data structure using the following operations:

  1. int get(int key) Return the value of the key if the key exists, otherwise return -1.
  2. void put(int key, int value) Update the value of the key if the key exists. Otherwise, add the key-value pair to the cache. If the number of keys exceeds the capacity from this operation, evict the least recently used key.
Read More

Docker. Logging.

Experiment with Docker continue! Now I need to configure logs using Fluentd. I have a next technical task:

  1. Create /data/logs directory on host system with 777 permitions.
  2. Run container with name fluentd with next parameters:
    • The container must be available on port 24224
    • /fluentd/log directory inside the container must be mounted to the /data/logs on host system
    • Image is fluentd:latest
  3. Run container with name nginx with next parameters:
    • Image is nginx:latest
    • Logging driver is fluentd
    • Fluentd server’s address is `127.0.0.1:24224’
Read More

Docker. Container and two networks.

This is a small hint for the case when you need to connect a container to two networks. Example:

docker network create cache # create network cache
docker network create front # create network front
docker create --name redis redis:latest # create container with name redis
docker network connect cache redis # connect network cache to container
docker network connect front redis # connect network front to container
docker start redis # start container
Read More