Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best Practice 3 - Cache: Local and remote strategy. #196

Open
barbara79 opened this issue Sep 30, 2020 · 0 comments
Open

Best Practice 3 - Cache: Local and remote strategy. #196

barbara79 opened this issue Sep 30, 2020 · 0 comments

Comments

@barbara79
Copy link
Contributor

barbara79 commented Sep 30, 2020

Commercetools resources are versioned, so it is possible to cache resources, since in case the cache is outdated we get a version conflict from the platform and all we have to do is invalidate the outdated cache entry.

We can use both cache strategies, either local, or remote (redis or other cach providers). but at the same time we dont want to bind ourselves to a specific provider, this is why we can create a cache interface that we use in a middleware. and which abstract the cache (local and remote ) away.

maybe use javax.persistence.Cache, or create an interface similar to

public interface CtpCache {
     Future<Object> upsert(String key, Object object);
     Future<Object> get(String key);
     void invalidate(String key);
}

public class CacheMiddleware {
        public CacheMiddleware(CtpCache cache){
        .....
        }
} 

linked to #192

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant