Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void populate(List<UUID> keys) {

public void populate(@NotNull UUID key) {
String cacheKey = generateCacheKey(key);
log.debug("populate(UUID key) method called with key: " + cacheKey);
RSemaphore semaphore = connection.getSemaphore(cacheKey+":semaphore");
semaphore.trySetPermits(1);

Expand All @@ -72,7 +73,7 @@ public void populate(@NotNull UUID key) {
next refresh will pick up data persisted by this thread
*/
if(queueSemaphore.tryAcquire()) {
log.debug("Attempting to refresh");
log.debug("Attempting to refresh for: " + cacheKey);
try {
// block until we get the green light to refresh the cache
semaphore.acquire();
Expand Down Expand Up @@ -110,6 +111,8 @@ public void populate(@NotNull UUID key) {
RMap<String, String> map = connection.getMap(cacheKey);
map.clear();
map.putAll(entryMap);
} else {
log.debug("No values to cache for key: " + cacheKey);
}
log.debug("cache loading complete for key: " + cacheKey);
} catch (Exception e) {
Expand Down Expand Up @@ -139,11 +142,11 @@ public Map<String, R> get(UUID key) throws ApiException {
if (!connection.getBucket(cacheKey).isExists()) {
RSemaphore semaphore = connection.getSemaphore(cacheKey + ":semaphore");
try {
log.debug("cache miss, populating");
log.debug("cache miss, populating for key: " + cacheKey);
populate(key);
//block until any updates are done
semaphore.acquire();
log.debug("Cache loading done!!!!");
log.debug("Cache loading done!!!! - key: " + cacheKey);
} catch(Exception e){
throw new ApiException(e);
} finally {
Expand Down