Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
0b1b121d
authored
2014-07-10 13:38:05 +0800
by
fuxiaohei
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
code style simplify
1 parent
8683ee7c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
cache/file.go
cache/file.go
View file @
0b1b121
...
...
@@ -135,11 +135,11 @@ func (fc *FileCache) Get(key string) interface{} {
func
(
fc
*
FileCache
)
Put
(
key
string
,
val
interface
{},
timeout
int64
)
error
{
gob
.
Register
(
val
)
item
:=
FileCacheItem
{
Data
:
val
}
item
:=
FileCacheItem
{
Data
:
val
}
if
timeout
==
FileCacheEmbedExpiry
{
item
.
Expired
=
time
.
Now
()
.
Unix
()
+
(
86400
*
365
*
10
)
// ten years
item
.
Expired
=
time
.
Now
()
.
Unix
()
+
(
86400
*
365
*
10
)
// ten years
}
else
{
item
.
Expired
=
time
.
Now
()
.
Unix
()
+
timeout
item
.
Expired
=
time
.
Now
()
.
Unix
()
+
timeout
}
item
.
Lastaccess
=
time
.
Now
()
.
Unix
()
data
,
err
:=
Gob_encode
(
item
)
...
...
@@ -166,7 +166,7 @@ func (fc *FileCache) Incr(key string) error {
if
reflect
.
TypeOf
(
data
)
.
Name
()
!=
"int"
{
incr
=
0
}
else
{
incr
=
data
.
(
int
)
+
1
incr
=
data
.
(
int
)
+
1
}
fc
.
Put
(
key
,
incr
,
FileCacheEmbedExpiry
)
return
nil
...
...
@@ -179,7 +179,7 @@ func (fc *FileCache) Decr(key string) error {
if
reflect
.
TypeOf
(
data
)
.
Name
()
!=
"int"
||
data
.
(
int
)
-
1
<=
0
{
decr
=
0
}
else
{
decr
=
data
.
(
int
)
-
1
decr
=
data
.
(
int
)
-
1
}
fc
.
Put
(
key
,
decr
,
FileCacheEmbedExpiry
)
return
nil
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment