Redis Info

some examples

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

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 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=1024 To update transparent hugepages settings in...

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

Build ID from Git (updated)

Posted by on May 28th, 2017 in GIT, Misc Tech | 0 comments

A simple build_id can be generated from Git via: git log --pretty=oneline | wc -l which will give you something like 9682 And while this will likely vary by branch, you really want to base a build id only from the branch you are deploying to production (in our case, release) anyway. It won’t let you name a work-in-progress, so that might be an issue for some people but also might enforce good practice by not letting you name a release until it’s “done”. As long as the naming is consistent, it should work. Of course in...

read more

Zip contents of current directory for Lambda

Posted by on May 11th, 2017 in Misc Tech | 0 comments

To create a AWS Lambda bundle, you need create a zip archive of your app directory that doesn’t contain a parent directory. To do this, cd to your app directory and execute: zip -r -X "../app.zip" *

read more

Override Docker Entrypoint properly

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

It’s not always so obvious what format the `ENTRYPOINT` override should take in a `docker run` command, so here is an example to clarify if you wanted to get a file list instead of the default entrypoint: first override the default ENTRYPOINT command with `/bin/ls` as a `run` argument then pass any args after the image name. docker run --entrypoint "/bin/ls" namespace/imagename -al /container/path/tolist As mentioned in the Docker docs, ENTRYPOINT only specifies the executable to run when the container...

read more

Docker copy files from image to local

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

You can’t easily copy file directly from a Docker image, but you can from a temporary container. Couple different ways to do it include: Run a temp container and copy into local mounted directory, here it’s a directory named “tmp” inside your current directory: docker run --rm -v $(pwd)/tmp:/tmp <image-name:tag> sh -c "cp -r /path/to/files/* /tmp" You could do additional pre/post processing and gather additional files as needed, etc. by updating the sh (or bash or other) command. Or you can...

read more

Docker stats with container names

Posted by on May 2nd, 2017 in Docker, Misc Tech | 0 comments

docker stats `docker ps | awk '{print $NF}' | grep -v NAMES`

read more

Docker remove orphaned volumes

Posted by on Apr 20th, 2017 in Docker, Misc Tech | 0 comments

docker volume rm $(docker volume ls -qf dangling=true)

read more

JSON parsing from the command-line

Posted by on Apr 19th, 2017 in Mac Tech, Misc Tech | 0 comments

You don’t need to use Python for basic JSON parsing, just use `jq`: jq – Command-line JSON processor see: https://stedolan.github.io/jq/manual/ http://support.gnip.com/articles/data-and-rule-management-with-jq.html etc.

read more

SSH bypass host checking for dev Docker environment

Posted by on Apr 19th, 2017 in Docker, Misc Tech | 0 comments

If you have a controlled environment where you are recreating SSH target instances, such as Docker containers, and have integration scripts (e.g., Jenkins), you will often run into SSH warnings that will prevent the CI/CD jobs from completing. If you are sure the target is in a controlled environment – e.g., within a Docker host/network, you can bypass the checks via: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no You could also update the UserKnownHostsFile but it can be tricky. There probably is a better setup than...

read more

No Responses to “ “Redis Info”

Trackbacks/Pingbacks

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

Leave a Reply