Caching and payment card

example of using correlation:

read input 

if (correlation-id is already generated for this input) 
{ 
   lookup the correlation-id from the cache; 
   return correlation-id; 
} 

else 
{ 
   generate the correlation-id; 
   cache it; 
   return correlation-id; 
} 

Limitations: - The number of input records can go up to 500K, therefore, does not want to use strong links. - Doesn't want to generate unidirectional hashes at the moment (I know that if we use a one-way hash, then there is no need to cache)

Can someone tell me how to use ComputingMap for this. I ask for this because javadoc has a note that says: "It uses the identifier equality for weak / soft keys."

+3
source share
1 answer

Google Guava/Collection , equals(), == . / , , . , , GC , .

, Google Equivalence , , equals() == , , .

Tuple equals() hashCode(),

new MapMaker()
    .softValues()
    .makeComputingMap(new Function<Tuple,String>() {
                                         public String apply(Tuple t) {
                                             // generate the correlation-id
                                         }
                                    });
+3

Source: https://habr.com/ru/post/1728529/


All Articles