| | |
| | | } |
| | | |
| | | const ( |
| | | PlcCacheKey = "plc:%v" |
| | | PlcCacheKey = "plc:%v:%v" |
| | | CurrentTaskCacheKey = "current_task" |
| | | CurrentProgressCacheKey = "current_progress" |
| | | CurrentProgressCacheKey = "current_progress:%v" |
| | | ) |
| | | |
| | | func PlcCacheGet(key string) (interface{}, bool) { |
| | | return defaultCacheStore.Get(fmt.Sprintf(PlcCacheKey, key)) |
| | | func PlcCacheGet(position int, key string) (interface{}, bool) { |
| | | return defaultCacheStore.Get(fmt.Sprintf(PlcCacheKey, position, key)) |
| | | } |
| | | |
| | | func PlcCacheSet(key string, value interface{}) { |
| | | defaultCacheStore.Add(fmt.Sprintf(PlcCacheKey, key), value) |
| | | func PlcCacheSet(position int, key string, value interface{}) { |
| | | defaultCacheStore.Add(fmt.Sprintf(PlcCacheKey, position, key), value) |
| | | } |
| | | |
| | | func TaskCacheSet(value *response.TaskData) { |
| | |
| | | return nil, false |
| | | } |
| | | |
| | | func ProgressCacheGet() (*model.ProductionProgress, bool) { |
| | | if v, ok := defaultCacheStore.Get(CurrentProgressCacheKey); ok { |
| | | func ProgressCacheGet(position int) (*model.ProductionProgress, bool) { |
| | | if v, ok := defaultCacheStore.Get(fmt.Sprintf(CurrentProgressCacheKey, position)); ok { |
| | | return v.(*model.ProductionProgress), ok |
| | | } |
| | | return nil, false |
| | | } |
| | | |
| | | func ProgressCacheSet(value *model.ProductionProgress) { |
| | | defaultCacheStore.Add(CurrentProgressCacheKey, value) |
| | | func ProgressCacheSet(position int, value *model.ProductionProgress) { |
| | | defaultCacheStore.Add(fmt.Sprintf(CurrentProgressCacheKey, position), value) |
| | | } |
| | | |
| | | func ProgressCacheUnset() { |
| | | defaultCacheStore.Remove(CurrentProgressCacheKey) |
| | | func ProgressCacheUnset(position int) { |
| | | defaultCacheStore.Remove(fmt.Sprintf(CurrentProgressCacheKey, position)) |
| | | } |