gitee.com/woood2/luca@v1.0.4/internal/cache/cache.go (about)

     1  package cache
     2  
     3  import (
     4  	"time"
     5  )
     6  /**
     7  Get case
     8  	var s *student
     9  	k:="student_1"
    10  	if err:=someCacheImpl.Get(k, &s); err!=nil{
    11  		if err==someCacheImpl.Miss(){
    12  			//do sth
    13  		}
    14  		//do sth
    15  	}
    16  */
    17  
    18  
    19  type Cache interface {
    20  	Get(k string, p interface{}) error
    21  
    22  	Set(k string, v interface{}, d time.Duration) error
    23  
    24  	Miss() error
    25  
    26  	ApplyToSet(k string) (ok bool, ch chan struct{}, e error)
    27  
    28  	Release(k string) error
    29  }