Skip to content

Commit

Permalink
Fix calculating expiration time (#18)
Browse files Browse the repository at this point in the history
Fix calculating expiration time
  • Loading branch information
goccy committed Nov 19, 2019
2 parents f00001d + 799d50a commit 9affe17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions server/memcache.go
Expand Up @@ -100,7 +100,7 @@ func (c *MemcachedClient) Set(req *CacheStoreRequest) error {
Flags: req.Key.Hash(),
Value: req.Value,
casid: req.CasID,
Expiration: int32(req.Expiration),
Expiration: int32(req.Expiration / time.Second),
}
if req.CasID != 0 {
if err := c.CompareAndSwap(item); err != nil {
Expand All @@ -119,7 +119,7 @@ func (c *MemcachedClient) Add(key CacheKey, value []byte, expiration time.Durati
&Item{
Key: key,
Value: value,
Expiration: int32(expiration),
Expiration: int32(expiration / time.Second),
},
(*MemcachedClient).add,
); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions server/redis.go
Expand Up @@ -88,7 +88,7 @@ func (c *RedisClient) Set(req *CacheStoreRequest) error {
Flags: req.Key.Hash(),
Value: req.Value,
casid: req.CasID,
Expiration: int32(req.Expiration),
Expiration: int32(req.Expiration / time.Second),
}

if err := c.onItem(
Expand All @@ -106,7 +106,7 @@ func (c *RedisClient) Add(key CacheKey, value []byte, expiration time.Duration)
&Item{
Key: key,
Value: value,
Expiration: int32(expiration),
Expiration: int32(expiration / time.Second),
},
(*RedisClient).add,
); err != nil {
Expand Down

0 comments on commit 9affe17

Please sign in to comment.