Redis Info

some examples

from SO:
Here’s one approach. Whenever a user views a product, create a key of the form,

and set this key’s expiry to 24 hours. After 24 hours this key will be deleted automatically. The value can be anything, but if you are interested in knowing exactly when the user viewed the product, then store the timestamp as the value of this key.

Searching for keys by pattern will allow you to make the above queries.

Get all users that a certain product in the last 24 hours.

KEYS user:*:products_viewed:5400

Get all products that a certain user viewed in the last 24 hours.

KEYS user:53:products_viewed:*

Get all products viewed by all users in the last 24 hours.

KEYS user:*:products_viewed:*

Docker swarm errors: check storage driver

Posted by on Jul 11th, 2018 in Docker, Misc Tech | 0 comments

After adding a new worker node to a swarm, it had errors including problems communicating with other services/containers on the overlay network (previously added nodes, both manager and worker, worked fine). It turned out that this newest node used a new installer that defaulted the storage driver to overlay2 — where the previously installed nodes were using aufs. All nodes are running on Ubuntu 16.04. You can check for support with the grep aufs /proc/filesystems command. If you don’t see any results, you may need to install sudo...

read more

Docker: fix terminal width issue

Posted by on Jul 2nd, 2018 in Docker, Misc Tech | 0 comments

Sometimes the terminal size reverts to the 80×24 default size, particularly when using Docker-in-Docker. To fix, pass the terminal specs when calling `docker run` or `docker exec`: docker run --rm -it -e COLUMNS=$COLUMNS -e LINES=$LINES -e TERM=$TERM -it ubuntu:16.04docker run --rm -it -e COLUMNS=$COLUMNS -e LINES=$LINES -e TERM=$TERM -it ubuntu:16.04 (see issue here)

read more

Simple Made Easy (link)

Posted by on May 10th, 2018 in Misc Tech | 0 comments

An oldie-but-good I was reminded of recently: Rich Hickey emphasizes simplicity’s virtues over easiness’, showing that while many choose easiness they may end up with complexity, and the better way is to choose easiness along the simplicity path. Sample takeaways: We should aim for simplicity because simplicity is a prerequisite for reliability. Simple is often erroneously mistaken for easy. “Easy” means “to be at hand”, “to be approachable”....

read more

Install amqp-ext PHP extension to Apache in Docker

Posted by on Feb 21st, 2018 in Apache, Docker, LAMP/Node, Misc Tech, PHP | 0 comments

I wanted to add RabbitMQ support to my PHP app and prefer to use the PECL amqp package: This extension can communicate with any AMQP spec 0-9-1 compatible server, such as RabbitMQ, OpenAMQP and Qpid, giving you the ability to create and delete exchanges and queues, as well as publish to any exchange and consume from any queue. Using pecl install won’t install all the dependencies. There are various options to how to solve this including fetching from Git repos, however this is the one that worked for me and seemed the most...

read more

Docker: get hash from image name

Posted by on Jan 1st, 2018 in Docker, Misc Tech | 0 comments

Particularly if you are using a static image name like “latest” or “develop”, it is useful to be able to know and verify the exact version via the sha256 hash. To get the value you can use: docker inspect --format='{{index .RepoDigests 0}}' repo/image-name:tagdocker inspect --format='{{index .RepoDigests 0}}' repo/image-name:tag To use this in a CI/CD workflow for Docker Swarm, you can do something like this: SHA=$(docker inspect --format='{{index .RepoDigests 0}}' repo/image-name:tag) docker service update...

read more

Remove Docker images with no tag

Posted by on Dec 13th, 2017 in Docker, Misc Tech | 0 comments

Sometimes, particularly on a development environment, you can end up with a lot of Docker images with no tags, which aren’t much practical use. To get rid of them you can do: docker rmi $(docker images | grep none | awk '{ print $3 }')docker rmi $(docker images | grep none | awk '{ print $3 }') Ones in use or with child images will not be deleted and result in output warning, but the rest will be removed so you can deal with the remaining ones as needed.

read more

Docker for Mac clock drift fix

Posted by on Dec 5th, 2017 in Docker, Misc Tech | 0 comments

It’s a pain, not sure if there is a “real” fix, but if your Docker host and Mac host clocks drift (presumably the Mac is correct), you can run: docker run --privileged --rm alpine date -s "$(date -u "+%Y-%m-%d %H:%M:%S")"docker run --privileged --rm alpine date -s "$(date -u "+%Y-%m-%d %H:%M:%S")" I’ve seen differences over 5 minutes, so worth checking…

read more

Recover deleted file from Git

Posted by on Aug 16th, 2017 in GIT, Misc Tech | 0 comments

To recover an old file from git where you don’t know the commit, you can do: git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file" Finds the last commit that affected the given path and checks out the file from there. Works on any file still in the history. If the file has not been staged or committed, simply use git checkout $file. From: SO

read more

Docker for Mac fix for max files, transparent hugepages warnings

Posted by on Jun 8th, 2017 in Docker, Mac Tech, Misc Tech | 0 comments

To avoid Redis and other apps’ “max files limit” and “transparent hugepages” etc errors in Docker containers on Docker for Mac, you can set sysctls options in your docker-compose file by using compose format 2.1 or greater, which should be supported in docker-compose >= 1.10. in docker-compose.yml file: version: '2.1' services: redis: image: redis:3.2-alpine command: redis-server /usr/local/etc/redis/redis.conf sysctls: - net.core.somaxconn=1024version: '2.1' services: redis: image:...

read more

Docker-in-docker Docker Compose with sshd

Posted by on May 29th, 2017 in Docker | 0 comments

Dockerfile: ## # Docker client with docker-compose && sshd # # use on a Docker host to allow you to ssh and access Docker and Compose remotely # e.g., as part of CI/CD on a private network. # ** Not for production use on publicly-exposed server ** # # mount for docker host socket: # -v /var/run/docker.sock:/var/run/docker.sock:ro # mount for docker-compose access (optional): # -v /host/compose/root:/opt/compose/alias # cd or reference -f /alias/to/docker-compose.yml file when using docker-compose ... #####   FROM...

read more

No Responses to “ “Redis Info”


  1. Redis page created | LDG Tech Blog - [...] link > Redis Page [...]

Leave a Reply