Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/valenciaj/gg-redis-pool

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/valenciaj/gg-redis-pool

  • v0.0.0-20180831172956-59e784689795
  • Source
  • Go
  • Socket score

Version published
Created
Source

Gin-Gonic Redis Pool Middleware

Simple redis pool middleware for Gin-Gonic framework.

This middleware set on each request a redis connection (new or pooled), and can be accessed with context Get("Redis") or MustGet("Redis") method.

package main

import (
		ggRedisPool "github.com/valenciaj/gg-redis-pool"
)

// Create server
srv := gin.Default()

dbConnStr =: "redis://@127.0.0.1:6379/0"

// Set middlewares
srv.Use(
	gin.Recovery(),
	ggRedisPool.Redis(dbConnStr),
)

// ... set other stuff ...

// Set routes
srv.GET("/", func(ctx *gin.Context) {

	// With Get method
	redisI, err := ctx.Get("Redis")
	if err != nil {
		panic(err)
	}
	// Unbox redis connection
	redis := redisI.(*DB)

	// With MustGet method
	redis := ctx.MustGet("Redis").(*DB)

	// ... do some stuff with redis connection ...

	// Response data
	ctx.HTML(200, "welcome/index.tmpl", gin.H{})
})

FAQs

Package last updated on 31 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc