Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/298#discussion_r211400520
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/cache/TenantCacheImpl.java ---
    @@ -77,57 +152,132 @@ public MemoryManager getMemoryManager() {
             return memoryManager;
         }
     
    -    private Cache<ImmutableBytesPtr,Closeable> getServerCaches() {
    +    private Cache<ImmutableBytesPtr,CacheEntry> getServerCaches() {
             /* Delay creation of this map until it's needed */
             if (serverCaches == null) {
                 synchronized(this) {
                     if (serverCaches == null) {
    -                    serverCaches = CacheBuilder.newBuilder()
    -                        .expireAfterAccess(maxTimeToLiveMs, 
TimeUnit.MILLISECONDS)
    -                        .ticker(getTicker())
    -                        .removalListener(new 
RemovalListener<ImmutableBytesPtr, Closeable>(){
    -                            @Override
    -                            public void 
onRemoval(RemovalNotification<ImmutableBytesPtr, Closeable> notification) {
    -                                
Closeables.closeAllQuietly(Collections.singletonList(notification.getValue()));
    -                            }
    -                        })
    -                        .build();
    +                    serverCaches = buildCache(maxTimeToLiveMs, false);
                     }
                 }
             }
             return serverCaches;
         }
    +
    +    private Cache<ImmutableBytesPtr,CacheEntry> 
getPersistentServerCaches() {
    +        /* Delay creation of this map until it's needed */
    +        if (persistentServerCaches == null) {
    +            synchronized(this) {
    +                if (persistentServerCaches == null) {
    +                    persistentServerCaches = 
buildCache(maxPersistenceTimeToLiveMs, true);
    +                }
    +            }
    +        }
    +        return persistentServerCaches;
    +    }
    +
    +    private Cache<ImmutableBytesPtr, CacheEntry> buildCache(final int ttl, 
final boolean isPersistent) {
    +        CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();
    +        if (isPersistent) {
    +            builder.expireAfterWrite(ttl, TimeUnit.MILLISECONDS);
    +        } else {
    +            builder.expireAfterAccess(ttl, TimeUnit.MILLISECONDS);
    +        }
    +        return builder
    +            .ticker(getTicker())
    +            .removalListener(new RemovalListener<ImmutableBytesPtr, 
CacheEntry>(){
    +                @Override
    +                public void 
onRemoval(RemovalNotification<ImmutableBytesPtr, CacheEntry> notification) {
    +                   if (isPersistent || 
!notification.getValue().getUsePersistentCache()) {
    --- End diff --
    
    Can we get some DEBUG/TRACE logging here? History has told me that being 
able to understand evictions about server-side caches in Phoenix is very useful 
;)


---

Reply via email to