Commit 12f36263 authored by vicotor's avatar vicotor

udpate

parent ada7f3f0
......@@ -9,7 +9,8 @@ import (
func (c *CacheData) GetTaskWithPath(path string) (*model.TaskType, error) {
// get from local cache
if v, exist := c.pathLru.Get(path); exist {
return v.(*model.TaskType), nil
task := v.(model.TaskType)
return &task, nil
}
// get id from redis and then get task from redis by id.
pathIdKey := "path-id:" + path
......@@ -17,7 +18,7 @@ func (c *CacheData) GetTaskWithPath(path string) (*model.TaskType, error) {
// get task from redis by id
if task, err := c.getTaskFromRedis(taskIdKey); err == nil {
// set task to local cache
c.pathLru.Add(path, task)
c.pathLru.Add(path, *task)
return task, nil
}
}
......@@ -30,7 +31,7 @@ func (c *CacheData) GetTaskWithPath(path string) (*model.TaskType, error) {
// set taskIdKey to redis
if err = c.rdb.Set(c.ctx, pathIdKey, taskIdKey, 0).Err(); err == nil {
// set task to local cache
c.pathLru.Add(path, task)
c.pathLru.Add(path, *task)
return task, nil
} else {
return nil, err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment