Real World Java EE Patterns--Rethinking Best Practices by Adam Bien

Real World Java EE Patterns--Rethinking Best Practices by Adam Bien

Author:Adam Bien [Bien, Adam]
Language: eng
Format: epub
Tags: COM051280
Publisher: http://press.adam-bien.com
Published: 2012-10-30T18:30:00+00:00


@Produces @Shared

public Cache shared(){

return cache;

}

}

The Cache is a plain Java interface:

public interface Cache {

void cache(String key,Object value);

Object fetch(String key);

}

The single implementation of this interface relies on the internal Map implementation:

public class InMemoryCache implements Cache{

private ConcurrentMap<String,Object> cache;

@PostConstruct

public void init(){

this.cache = new ConcurrentHashMap<>();

}

@Override

public void cache(String key,Object value){

this.cache.put(key, value);

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.