From f1f9f3b4780b2ebb3a46340f085862248d118d60 Mon Sep 17 00:00:00 2001 From: Mervyn Sim Date: Sat, 26 Oct 2019 14:47:24 +0800 Subject: [PATCH] Fixes gpkc/nameko-microservices/#3 - uses hmset and hgetall to store and retrieve a dictionary with redis --- docker-compose.yml | 5 +++-- trips/trips.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index cb45b1a..9ecaac2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,7 @@ services: - redis-data:/data rabbit: - image: rabbitmq:3.6-management + image: rabbitmq:3-management ports: - "15672:15672" @@ -53,4 +53,5 @@ services: RABBIT_PORT: "5672" volumes: - redis-data: \ No newline at end of file + redis-data: + diff --git a/trips/trips.py b/trips/trips.py index 8b64088..ed8cc76 100644 --- a/trips/trips.py +++ b/trips/trips.py @@ -11,13 +11,13 @@ class TripsService: @rpc def get(self, trip_id): - trip = self.redis.get(trip_id) + trip = self.redis.hgetall(trip_id) return trip @rpc def create(self, airport_from_id, airport_to_id): trip_id = uuid.uuid4().hex - self.redis.set(trip_id, { + self.redis.hmset(trip_id, { "from": airport_from_id, "to": airport_to_id })