Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d769f09

Browse filesBrowse files
committed
Merge pull request revel#740 from klauspost/redis-cache-add-timeout
Redis Cache: Add timeouts.
2 parents 3d1cc2c + ae3d108 commit d769f09
Copy full SHA for d769f09

File tree

Expand file treeCollapse file tree

1 file changed

+4
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-1
lines changed

‎cache/redis.go

Copy file name to clipboardExpand all lines: cache/redis.go
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ func NewRedisCache(host string, password string, defaultExpiration time.Duration
2020
IdleTimeout: time.Duration(revel.Config.IntDefault("cache.redis.idletimeout", 240)) * time.Second,
2121
Dial: func() (redis.Conn, error) {
2222
protocol := revel.Config.StringDefault("cache.redis.protocol", "tcp")
23-
c, err := redis.Dial(protocol, host)
23+
toc := time.Millisecond * time.Duration(revel.Config.IntDefault("cache.redis.timeout.connect", 10000))
24+
tor := time.Millisecond * time.Duration(revel.Config.IntDefault("cache.redis.timeout.read", 5000))
25+
tow := time.Millisecond * time.Duration(revel.Config.IntDefault("cache.redis.timeout.write", 5000))
26+
c, err := redis.DialTimeout(protocol, host, toc, tor, tow)
2427
if err != nil {
2528
return nil, err
2629
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.