Author Archives: xJohnwu

About xJohnwu

Strive to be an IT geek

Redis on Windows

Website: https://redis.io/

Installation:

  1. Redis supports Unix system so in order to support Windows it requires some tweaks. You can download the MSI at https://github.com/MSOpenTech/redis#redis-on-windows
  2. In python environment:
    pip install redis

One simple example to set and get string values

import redis

r = redis.Redis()
r.set('foo', 'bar')
value = r.get('foo').decode('utf-8')
print(value)

Note: r.get('foo') will return b'bar' which is a byte string – redis will auto-encode a unicode string for you on the way in. r.get('foo').decode('utf-8') decode it using utf-8.

Ref: https://stackoverflow.com/questions/25745053/about-char-b-prefix-in-python3-4-1-client-connect-to-redis

You can even save objects

class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age

    def grow(self):
        self.age += 1

    def __repr__(self):
        return str.format("Name={name}, Age={age}", name=self.name, age=self.age)

p = Person("Han", 32)
r.set('han', p)

Have fun!

Pure carrot, no sticks

The below quote is taken from Lessons Learned From Scaling Uber To 2000 Engineers, 1000 Services, And 8000 Git Repositories

  • Pure carrots, no sticks. This is a deep point about the role of command and control is such a large diverse group. You’ll be tempted to mandate policy. Thou shalt log this way, for example. If you don’t there will be consequences. That’s the stick. Matt says don’t do that. Use carrots instead. Any time the sticks come out it’s bad. So no mandates. The way you want to handle it is provide tools that are so obvious and easy to use that people wouldn’t do it any other way.

Other things to take away:

  1. Minimal performance metrics and tracing in base application layer
  2. Common dash-board etc so that people can understand metrics from other services (maintained by some other people)