revelRedis

package module
v0.0.0-...-f6f8531 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2017 License: MIT Imports: 3 Imported by: 0

README

Revel Redis

A simple Redis module for the Revel Framework. Adds a shared gosexy/redis client to any controller, with a shared connection across all requests.

Usage

To get started, add the revel-redis module and config to conf/app.conf

NOTICE: You'd better add this in the body of the conf/app.conf, not append it at the bottom, which leads to empty value. For example you may just copy this and paste it under the http.sslkey section.

############# Redis Connection Info ##########
module.redis=github.com/snikch/revel-redis
redis.host = 127.0.0.1
#Optional
redis.port = 6379
#Optional
redis.password =
##############################################

If you want to use an environment variable instead of a hardcoded conf value, see https://revel.github.io/manual/appconf.html#environment-variables

Now in any controller you want some Redis action, import the library, and add the RedisController to your controller struct.


import "github.com/snikch/revel-redis"

type MyController struct {
	*revel.Controller
	revelRedis.RedisController
}

Now you can feel free to access Redis on your controller

func (c *MyController) DoStuff() revel.Result{
	return c.RenderText(c.Redis.Keys("*"))
}

Who

Created with love by Mal Curtis

Twitter: snikchnz

License

MIT. See license file.

Todo

  • Handle global processes when starting another instance of hack

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Documentation

Overview

This module configures a redis connect for the application

Index

Constants

This section is empty.

Variables

View Source
var (
	Redis *redis.Client
)

Functions

func Init

func Init()

Types

type RedisController

type RedisController struct {
	*revel.Controller
	Redis *redis.Client
}

func (*RedisController) Begin

func (c *RedisController) Begin() revel.Result

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL