How to manage open connections to Redis or any database in general?

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/golang

Our great sponsors
  • SonarLint - Deliver Cleaner and Safer Code - Right in Your IDE of Choice!
  • Scout APM - Less time debugging, more time building
  • SaaSHub - Software Alternatives and Reviews
  • Redis

    Type-safe Redis client for Golang (by go-redis)

    I have a program in go that will open a new connection for each request. with a massive concurrent requests, redis goes down. I though why not i create a concurrent safe singleton pattern like this https://play.golang.org/p/BYxuXN16HlV. Do you think this approach is good or do u have a different approach. I know in mysql drive they handle the maximum number of open connections but it doesn't seem that's the case for this Redis package https://github.com/go-redis/redis

  • go-dependency-injection-example

    An example to demonstrate the dependency injection pattern in Go

    IMO you should avoid package level state and use dependency injection to pass the DB reference to your HTTP handlers. I found an example here https://github.com/sohamkamani/go-dependency-injection-example

  • SonarLint

    Deliver Cleaner and Safer Code - Right in Your IDE of Choice!. SonarLint is a free and open source IDE extension that identifies and catches bugs and vulnerabilities as you code, directly in the IDE. Install from your favorite IDE marketplace today.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts