default: .
# first we must setup the test database
- sudo docker stop redis || true
- sudo docker rm redis || true
sudo docker run -d --name redis -p 6379:6379 redis:latest
python3 ./testing/dummy_testing_data.py
# now we can run the main app with the right arguments
go build .
- ./songmanager -port 8000 -binb_location="" -songs_location="" -redis_location="localhost:6379" -container_name=""
+ ./songmanager -port 8000 -binb_location="" -songs_location="" -redis_location="localhost:6379" -container_name="" || true
+
+ docker stop redis || true
+ docker rm redis || true
import (
"context"
- "fmt"
+ "encoding/json"
"net/http"
"github.com/redis/go-redis/v9"
)
+type DBStatusMessage struct {
+ TotalSongCount int
+}
+
type DBWrapper struct {
RedisDb *redis.Client
ctx context.Context
return
}
- fmt.Println(dbw.RedisDb.Keys(dbw.ctx, "song"))
+ keys, err := dbw.RedisDb.Keys(dbw.ctx, "song:*").Result()
+ if err != nil {
+ panic(err)
+ }
+ key_count := len(keys)
+
+ m := DBStatusMessage{
+ TotalSongCount: key_count,
+ }
+ b, err := json.Marshal(m)
+ if err != nil {
+ panic(err)
+ }
+
+ w.Write(b)
}
import redis
+
def main():
r = redis.Redis(host="localhost", port="6379", decode_responses=True)
"artistNames": "firstartist, secondartist",
"songNames": "firstsongname, secondsongname"
})
- r.zadd("hits", { i: i } )
-
-
+ r.zadd("hits", {i: i})
if __name__ == "__main__":