karlseguin / ccache

A golang LRU Cache for high concurrency
MIT License
1.28k stars 119 forks source link

cannot use cvalue.Value() (type interface {}) as type int in assignment: need type assertion #14

Closed unisqu closed 6 years ago

unisqu commented 6 years ago

cannot use cvalue.Value() (type interface {}) as type int in assignment: need type assertion

            userid := 1
            intvalue := 1 //initial value
            cvalue := cache.Get(userid)
            if(cvalue!=nil){
                    intvalue = cvalue.Value() //what is wrong with this line?
            }else{
                    cache.Set(userid, 2, time.Second * 1)
           }

pls help. thanks

unisqu commented 6 years ago

solved. sorry about this. not sure why it didnt work the first time.