-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move caching of Table and Ref into new classes
Also use singleton for caching
- Loading branch information
dolfinus
committed
Jun 29, 2019
1 parent
1be3bef
commit 1cad6b6
Showing
4 changed files
with
95 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.camunda.latera.bss.internal | ||
|
||
import java.math.BigInteger | ||
import java.util.concurrent.ConcurrentHashMap | ||
import static org.camunda.latera.bss.utils.Numeric.toIntSafe | ||
|
||
class RefCache { | ||
private Map<String, BigInteger> map; | ||
private static final RefCache instance = new RefCache(); | ||
|
||
static RefCache getInstance() { | ||
return instance; | ||
} | ||
|
||
private RefCache() { | ||
map = new ConcurrentHashMap<String, BigInteger>(); | ||
} | ||
|
||
void put(CharSequence key, def value) { | ||
if (key != null && value != null) { | ||
map[key.toString()] = toIntSafe(value) | ||
} | ||
} | ||
|
||
def get(CharSequence key) { | ||
return map[key.toString()] | ||
} | ||
|
||
def putAndGet(CharSequence key, def value) { | ||
put(key, value) | ||
return get(key) | ||
} | ||
|
||
def getKey(def value) { | ||
BigInteger val = toIntSafe(value) | ||
return map.find{it.value == val}?.key | ||
} | ||
|
||
String putAndGetKey(CharSequence key, def value) { | ||
put(key, value) | ||
return key.toString() | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/org/camunda/latera/bss/internal/TableColumnCache.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.camunda.latera.bss.internal | ||
|
||
import java.util.concurrent.ConcurrentHashMap | ||
|
||
class TableColumnCache { | ||
private Map<String, List> map; | ||
private static final TableColumnCache instance = new TableColumnCache(); | ||
|
||
static TableColumnCache getInstance() { | ||
return instance; | ||
} | ||
|
||
private TableColumnCache() { | ||
map = new ConcurrentHashMap<String, List>(); | ||
} | ||
|
||
void put(CharSequence key, List value) { | ||
if (key != null && value != null) { | ||
map[key.toString()] = value | ||
} | ||
} | ||
|
||
def get(CharSequence key) { | ||
return map[key.toString()] | ||
} | ||
|
||
def putAndGet(CharSequence key, def value) { | ||
put(key, value) | ||
return get(key) | ||
} | ||
} |