diff --git a/grails-app/services/io/xh/toolbox/admin/TestCacheService.groovy b/grails-app/services/io/xh/toolbox/admin/TestCacheService.groovy index 3139a56cc..33359797c 100644 --- a/grails-app/services/io/xh/toolbox/admin/TestCacheService.groovy +++ b/grails-app/services/io/xh/toolbox/admin/TestCacheService.groovy @@ -3,7 +3,7 @@ package io.xh.toolbox.admin import groovy.transform.CompileStatic import io.xh.hoist.BaseService import io.xh.hoist.cache.Cache -import io.xh.hoist.cache.CacheValueChanged +import io.xh.hoist.cache.CacheEntryChanged import java.time.LocalDate @@ -17,7 +17,7 @@ class TestCacheService extends BaseService { private Cache resultCache = createCache( name: 'result', replicate: true, - onChange: {CacheValueChanged e -> + onChange: { CacheEntryChanged e -> logDebug(e.source.name, [key: e.key, value: e.value]) } ) @@ -27,7 +27,7 @@ class TestCacheService extends BaseService { expireTime: {30*SECONDS}, replicate: true, serializeOldValue: true, - onChange: { CacheValueChanged e -> + onChange: { CacheEntryChanged e -> logDebug(e.source.name, [key: e.key, value: e.value, oldValue: e.oldValue]) } ) diff --git a/grails-app/services/io/xh/toolbox/admin/TestCachedValueService.groovy b/grails-app/services/io/xh/toolbox/admin/TestCachedValueService.groovy index fdbd60a0d..4df15b6cc 100644 --- a/grails-app/services/io/xh/toolbox/admin/TestCachedValueService.groovy +++ b/grails-app/services/io/xh/toolbox/admin/TestCachedValueService.groovy @@ -2,13 +2,12 @@ package io.xh.toolbox.admin import groovy.transform.CompileStatic import io.xh.hoist.BaseService -import io.xh.hoist.cache.CacheValueChanged -import io.xh.hoist.cache.CachedValue +import io.xh.hoist.cachedvalue.CachedValue +import io.xh.hoist.cachedvalue.CachedValueChanged import static io.xh.hoist.util.DateTimeUtils.SECONDS import static io.xh.toolbox.admin.TestUtils.generatePrice import static io.xh.toolbox.admin.TestUtils.generateResultSet -import static java.lang.Thread.sleep @CompileStatic class TestCachedValueService extends BaseService { @@ -16,8 +15,8 @@ class TestCachedValueService extends BaseService { private CachedValue resultValue = createCachedValue( name: 'result', replicate: true, - onChange: {CacheValueChanged e -> - logDebug(e.source.name, [key: e.key, value: e.value]) + onChange: {CachedValueChanged e -> + logDebug(e.source.name, [value: e.value]) } ) @@ -25,9 +24,8 @@ class TestCachedValueService extends BaseService { name: 'price', expireTime: 30*SECONDS, replicate: true, - serializeOldValue: true, - onChange: { CacheValueChanged e -> - logDebug(e.source.name, [key: e.key, value: e.value, oldValue: e.oldValue]) + onChange: { CachedValueChanged e -> + logDebug(e.source.name, [value: e.value, oldValue: e.oldValue]) } ) @@ -35,26 +33,22 @@ class TestCachedValueService extends BaseService { void init() { super.init() - initData() + if (isPrimary) initData() + resultValue.ensureAvailable() } private void initData() { - if (isPrimary) { - sleep(15 * SECONDS) // Simulate delay to generate results - resultValue.set(generateResultSet()) - priceValue.getOrCreate { - generatePrice() - } + resultValue.set(generateResultSet()) + priceValue.getOrCreate { + generatePrice() } - resultValue.ensureAvailable() - - logInfo('Values', allValues.collectEntries { [it.name, it.get()]}) + logInfo('Values', allValues.collectEntries { [it.name, it.get()] }) } void clearCaches() { super.clearCaches() allValues.each {it.clear()} - initData() + if (isPrimary) initData() } Map getAdminStats() { diff --git a/grails-app/services/io/xh/toolbox/admin/TestSerializationService.groovy b/grails-app/services/io/xh/toolbox/admin/TestSerializationService.groovy index 4b2653410..d8f8887c3 100644 --- a/grails-app/services/io/xh/toolbox/admin/TestSerializationService.groovy +++ b/grails-app/services/io/xh/toolbox/admin/TestSerializationService.groovy @@ -12,7 +12,7 @@ import com.esotericsoftware.kryo.KryoSerializable import com.esotericsoftware.kryo.io.Input import com.esotericsoftware.kryo.io.Output import io.xh.hoist.BaseService -import io.xh.hoist.cache.CachedValue +import io.xh.hoist.cachedvalue.CachedValue import io.xh.hoist.log.LogSupport diff --git a/grails-app/services/io/xh/toolbox/app/NewsService.groovy b/grails-app/services/io/xh/toolbox/app/NewsService.groovy index 14713c030..d5214147f 100644 --- a/grails-app/services/io/xh/toolbox/app/NewsService.groovy +++ b/grails-app/services/io/xh/toolbox/app/NewsService.groovy @@ -2,7 +2,7 @@ package io.xh.toolbox.app import io.xh.hoist.BaseService -import io.xh.hoist.cache.CachedValue +import io.xh.hoist.cachedvalue.CachedValue import io.xh.hoist.http.JSONClient import io.xh.toolbox.NewsItem import org.apache.hc.client5.http.classic.methods.HttpGet diff --git a/grails-app/services/io/xh/toolbox/portfolio/PortfolioService.groovy b/grails-app/services/io/xh/toolbox/portfolio/PortfolioService.groovy index bfbcc7438..d08452a2a 100644 --- a/grails-app/services/io/xh/toolbox/portfolio/PortfolioService.groovy +++ b/grails-app/services/io/xh/toolbox/portfolio/PortfolioService.groovy @@ -2,7 +2,7 @@ package io.xh.toolbox.portfolio import com.hazelcast.replicatedmap.ReplicatedMap import io.xh.hoist.BaseService -import io.xh.hoist.cache.CachedValue +import io.xh.hoist.cachedvalue.CachedValue import io.xh.hoist.exception.DataNotAvailableException import java.time.* diff --git a/grails-app/services/io/xh/toolbox/security/AuthenticationService.groovy b/grails-app/services/io/xh/toolbox/security/AuthenticationService.groovy index 275317cfb..2c9690d68 100755 --- a/grails-app/services/io/xh/toolbox/security/AuthenticationService.groovy +++ b/grails-app/services/io/xh/toolbox/security/AuthenticationService.groovy @@ -38,7 +38,7 @@ class AuthenticationService extends BaseAuthenticationService { } def token = request.getHeader('x-xh-idt'), - tokenResult = auth0Service.validateToken(token) + tokenResult = token ? auth0Service.validateToken(token) : null if (tokenResult) { def user = userService.getOrCreateFromTokenResult(tokenResult) setUser(request, user)