Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
5b1afcdb
Commit
5b1afcdb
authored
Dec 24, 2013
by
傅小黑
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add timeout description for file and memory cache.
parent
053e7a6a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
file.go
cache/file.go
+2
-1
memory.go
cache/memory.go
+2
-1
No files found.
cache/file.go
View file @
5b1afcdb
...
...
@@ -144,12 +144,13 @@ func (this *FileCache) Get(key string) interface{} {
// Put value into file cache.
// timeout means how long to keep this file, unit of ms.
// if timeout equals FileCacheEmbedExpiry(default is 0), cache this item forever.
func
(
this
*
FileCache
)
Put
(
key
string
,
val
interface
{},
timeout
int64
)
error
{
filename
:=
this
.
getCacheFileName
(
key
)
var
item
FileCacheItem
item
.
Data
=
val
if
timeout
==
FileCacheEmbedExpiry
{
item
.
Expired
=
time
.
Now
()
.
Unix
()
+
(
86400
*
365
*
10
)
//
10年
item
.
Expired
=
time
.
Now
()
.
Unix
()
+
(
86400
*
365
*
10
)
//
ten years
}
else
{
item
.
Expired
=
time
.
Now
()
.
Unix
()
+
timeout
}
...
...
cache/memory.go
View file @
5b1afcdb
...
...
@@ -26,7 +26,7 @@ type MemoryCache struct {
lock
sync
.
RWMutex
dur
time
.
Duration
items
map
[
string
]
*
MemoryItem
Every
int
// run an expiration check Every cloc
;
time
Every
int
// run an expiration check Every cloc
k
time
}
// NewMemoryCache returns a new MemoryCache.
...
...
@@ -52,6 +52,7 @@ func (bc *MemoryCache) Get(name string) interface{} {
}
// Put cache to memory.
// if expired is 0, it will be cleaned by next gc operation ( default gc clock is 1 minute).
func
(
bc
*
MemoryCache
)
Put
(
name
string
,
value
interface
{},
expired
int64
)
error
{
bc
.
lock
.
Lock
()
defer
bc
.
lock
.
Unlock
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment