Skip to content

Commit

Permalink
Merge pull request #5 from thinkoner/develop
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
leeqvip authored Jan 28, 2019
2 parents 991903d + 41d1304 commit a41a044
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func main() {
- [View](#view)
- [HTTP Session](#http-session)
- [Logging](#logging)
- [Cache](#cache)
- [ORM](#orm)

## Routing
Expand Down Expand Up @@ -399,6 +400,46 @@ log.Alert("log with Alert")
log.Emerg("log with Emerg")
```

## Cache

ThinkGo Cache Currently supports redis, memory, and can customize the store adapter.

#### Basic Usage

```go
import (
"github.com/thinkoner/thinkgo/cache"
"time"
)


var foo string

// Create a cache with memory store
c, _ := cache.Cache(cache.NewMemoryStore("thinkgo"))

// Set the value
c.Put("foo", "thinkgo", 10 * time.Minute)

// Get the string associated with the key "foo" from the cache
c.Get("foo", &foo)

```

#### Retrieve & Store

Sometimes you may wish to retrieve an item from the cache, but also store a default value if the requested item doesn't exist. For example, you may wish to retrieve all users from the cache or, if they don't exist, retrieve them from the callback and add them to the cache. You may do this using the `Remember` method:

```go
var foo int

cache.Remember("foo", &a, 1*time.Minute, func() interface{} {
return "thinkgo"
})
```

refer to [ThinkGo Cache]( https://github.com/thinkoner/thinkgo/tree/master/cache )

## ORM

refer to [ThinkORM]( https://github.com/thinkoner/thinkorm )
Expand Down

0 comments on commit a41a044

Please sign in to comment.