github.com/ernestokarim/closurer@v0.0.0-20130119214741-f245d086c750/cache/data.go (about)

     1  package cache
     2  
     3  import (
     4  	"github.com/ernestokarim/closurer/config"
     5  )
     6  
     7  var dataCache = map[string]interface{}{}
     8  
     9  // Read some data of the cache with the key. If the data it's not present,
    10  // blank will be returned.
    11  func ReadData(key string, blank interface{}) interface{} {
    12  	d, ok := dataCache[key]
    13  	if !ok || config.NoCache {
    14  		dataCache[key] = blank
    15  		return blank
    16  	}
    17  
    18  	return d
    19  }