Skip to content

neko-contrib/cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Cache wercker status GoDoc GoCover

Neko handler for cache management.

Usage

package main

import (
  "time"
  "github.com/rocwong/neko"
  nc "github.com/neko-contrib/cache"
)

func main() {
  app := neko.Classic()
  app.Use(nc.Generate(nc.Options{}))

  m.GET("/", func(ctx *neko.Context) {
    cache := ctx.MustGet(nc.MemoryStore).(nc.Cache)
    cache.Set("foo", "bar", 10 * time.Second)
  })

  m.GET("/get", func(ctx *neko.Context) {
    cache := ctx.MustGet(nc.MemoryStore).(nc.Cache)
    v, found := cache.Get("foo")
    ctx.Text(v.(string))
  })

  app.Run(":3000")
}

Options

cache.Options {
  // Store cache store. Default is 'MemoryStore'
  Store string
  // Config stores configuration.
  Config string
  // Interval GC interval time in seconds. Default is 60.
  Interval int
}

Stores

Memory

app.Use(cache.Generate(cache.Options{}))

About

Neko handler for cache management.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages