이 질문에 대한 대답은 분명해 보이지만 완전히 확신해야합니다. 따라서 대답이 명확하고 모호하지 않은 진술을 사용하여 권위있는 참조를 제공 할 수 있다면 그것은 훌륭 할 것입니다. MemcacheService는 근본적으로 싱글 톤입니까
내가public CollectionResponse<Dog> getDogs(Identification request){
MemcacheService syncCacheDog = MemcacheServiceFactory.getMemcacheService();
syncCacheDog.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
// ........
value = (byte[]) syncCacheDog.get(key); // read from cache
if (value == null) {
// get value from other source
// ........
syncCacheDog.put(key, value); // populate cache
}
// ........
}
public CollectionResponse<Cat> getCats(Identification request){
MemcacheService syncCacheCat = MemcacheServiceFactory.getMemcacheService();
syncCacheCat.setErrorHandler(ErrorHandlers.getConsistentLogAndContinue(Level.INFO));
// ........
value = (byte[]) syncCacheCat.get(key); // read from cache
if (value == null) {
// get value from other source
// ........
syncCacheCat.put(key, value); // populate cache
}
// ........
}
이 syncCacheDog 및 syncCacheCat이 같은지도를 가리키는 다음 두 가지 방법을 말해? 또는 나는, 그들이 같은지도를 가리키는 싶은 경우에 나는 두 가지 방법 내부
static MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
후 사용 syncCache
를 작성해야합니까?
반면에 싱글 톤인 경우 두 개의 다른 캐시를 어떻게 유지합니까? 나는. 누군가가 내 방법 중 하나를 복사하여 붙여 넣을 수 있고 네임 스페이스로 작성된 것을 보여 주며 Dog와 같은 특정 객체를 처리하기 위해 제네릭 바이트를 처리하는 대신 표시 할 수 있습니까?