Skip to content

This is a high-performance framework for saving cached results.

Notifications You must be signed in to change notification settings

zhengzhanpeng/efficient_cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intent

Efficient cache result is a high-performance framework for saving cached results.It tries to solve the performance problems of some algorithms in high concurrency situations. UML

Explanation

It almost does not lock to complete the results cache and get the results.In the case of concurrency, when need a result, the result is taken immediately if it has already been calculated.

Applicability

  • You frequently calculate a value
  • You want to safely save the results under concurrency conditions
  • You do not want to lock when saving results

Tutorials

First you should new a entity class of Compute.

//java 1.8
Compute<Long, Long> compute = EfficientCacheCompute.<Long, Long>createNeedComputeFunction(key -> key += 1);
//java 1.7
Compute<Long, Long> compute = EfficientCacheCompute.<Long, Long>createNeedComputeFunction(new Function<Long, Long>() {
    @Override
    public Long apply(Long key) {
        key += 1;
        return key;
    }
});

Second, each call to the compute method begins

long key = 12;
long result = compute.compute(key);

You can also specify any type of object as KeyT and ResultT to make sure your algorithm is more flexible.

About

This is a high-performance framework for saving cached results.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages