code: protected void cacheElement(
              Ehcache cache,
              Serializable cacheKey,
              CachedPortletResultHolder<?> data,
              CacheControl cacheControl) {
          // using validation method, ignore expirationTime and defer to cache configuration
          if (cacheControl.getETag() != null) {
              final Element element = new Element(cacheKey, data);
              cache.put(element);
              return;
          }
  
          // using expiration method, -1 for CacheControl#expirationTime means "forever" (e.g. ignore
          // and defer to cache configuration)
          final int expirationTime = cacheControl.getExpirationTime();
          if (expirationTime == -1) {
              final Element element = new Element(cacheKey, data);
              cache.put(element);
              return;
          }
  
          // using expiration method with a positive expiration, set that value as the element's TTL
          // if it is lower than the configured cache TTL
          final CacheConfiguration cacheConfiguration = cache.getCacheConfiguration();
          final Element element = new Element(cacheKey, data);
          final long cacheTTL = cacheConfiguration.getTimeToLiveSeconds();
          if (expirationTime < cacheTTL) {
              element.setTimeToLive(expirationTime);
          }
          cache.put(element);
      }
docs: Construct an appropriate Cache {@link Element} for the cacheKey and data. The element's ttl
  will be set depending on whether expiration or validation method is indicated from the
  CacheControl and the cache's configuration.