示例#1
0
func myCacheReadHandler(ctx *macaron.Context, c cache.Cache) interface{} {
	val := c.Get(ctx.Params(":key"))
	if val != nil {
		return val
	} else {
		return fmt.Sprintf("no cache with \"%s\" set", ctx.Params(":key"))
	}
}
示例#2
0
func myCacheWriteHandler(ctx *macaron.Context, c cache.Cache) string {
	c.Put(ctx.Params(":key"), ctx.Params(":value"), 300)
	return "cached for 5 minutes"
}