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:*

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 -lgit 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...

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 "../" *zip -r -X "../" *

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/tolistdocker run --entrypoint "/bin/ls" namespace/imagename -al /container/path/tolist As mentioned in the Docker docs,...

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"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...

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`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 prunedocker volume prune see: commandline/volume_prune/ to remove all unused containers, networks, images (both dangling and unreferenced), and optionally, volumes: docker system prune [--all --volumes]docker system prune [--all --volumes] see: commandline/system_prune Alternate method: docker volume rm $(docker volume ls -qf dangling=true)docker volume rm $(docker volume ls -qf...

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: 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=nossh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no You could also update the...

read more

Recreate single Docker container using docker-compose

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

Often you want to restart a container that you started using docker-compose and have it recreate the container due to some config change. If you pull a new image, it will usually recreate the container but simply updating the compose file will not. Using `up` with `–no-deps` should do the trick for a stopped container. (Note example below uses background process `-d` arg.( docker-compose stop service {docker-compose build/pull/edit config/etc} service docker-compose up -d --no-deps servicedocker-compose stop...

read more

Consumer-Driven Contracts: links

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

I like the idea of CDC, certainly easier to aspire to than to implement, would be interested to hear actual success stories. Also the examples showing 1-to-1 matching criteria seem to against the intention of “not caring exactly what the data is, as long as it satifies my needs”. Consumer-Driven Contracts: A Service Evolution Pattern Also seems like a...

read more

No Responses to “ “Redis Info”


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

Leave a Reply