Class SimpleCachingHive

  • All Implemented Interfaces:
    Hive

    public class SimpleCachingHive
    extends BasicHive
    A very simple caching mechanism on top of BasicHive. If you want more control over your cache you could for example use EHCache and extend BasicHive yourself. This cache is cleared when a subject logs off but no guarantees are given that the cache will not be cleared prematurely or how long it takes after a user logs off to clear the cached results.
    Author:
    marrink
    • Constructor Detail

      • SimpleCachingHive

        public SimpleCachingHive()
    • Method Detail

      • cacheLookUp

        protected Boolean cacheLookUp​(Subject subject,
                                      Permission permission)
        Description copied from class: BasicHive
        Allows subclasses to retrieve previously cached results and thus speed up the check. By default null is returned, meaning no cached value
        Overrides:
        cacheLookUp in class BasicHive
        Parameters:
        subject - (optional) subject
        permission - the permission to check
        Returns:
        null if there is no cached value, true if the permission is granted, false if the permission is denied
      • cacheResult

        protected void cacheResult​(Subject subject,
                                   Permission permission,
                                   boolean result)
        Description copied from class: BasicHive
        Allows subclasses to cache the result of a check and thus speed up this check the next time. By default this method does not have an implementation.
        Overrides:
        cacheResult in class BasicHive
        Parameters:
        subject - (optional) subject
        permission - the permission to check
        result - the result of the permission