Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default Maximum Size for a Google Guava Cache?

Tags:

guava

Given a Guava cache created with the code below is there a maximum cache size if one is not set?

LoadingCache<String, String> loadingCache = CacheBuilder.newBuilder().build(new CacheLoader<String, String>() {
    @Override
    public String load(String key) throws Exception
    {
        return key.toUpperCase();
    }
});

In my case I really want a cache with no upper bound in size. I am using the cache to store permissions for logged in users and will evict items from the cache on user logout or session expiry.

like image 661
ams Avatar asked Jul 13 '12 03:07

ams


Video Answer


1 Answers

The default cache is unbounded: as the javadoc for CacheBuilder explains

These features are all optional

and

By default cache instances created by CacheBuilder will not perform any type of eviction.

like image 84
Frank Pavageau Avatar answered Nov 11 '22 15:11

Frank Pavageau