Class PreparedQueryCacheImpl

    • Constructor Detail

      • PreparedQueryCacheImpl

        public PreparedQueryCacheImpl()
    • Method Detail

      • register

        public java.lang.Boolean register​(java.lang.String id,
                                          Query query,
                                          FetchConfiguration hints)
        Description copied from interface: PreparedQueryCache
        Register the given query for caching against the given key if it has not already been cached. If the query can not be cached, then mark it as such to avoid computing for the same key again.
        Specified by:
        register in interface PreparedQueryCache
        Returns:
        TRUE the query is registered in the cache by this call null if the query is already registered in the cache FALSE if can not be registered in the cache, either because it is known not to be cacheable from a previous attempt or a hint is given to ignore the cached version.
      • getMapView

        public java.util.Map<java.lang.String,​java.lang.String> getMapView()
        Description copied from interface: PreparedQueryCache
        Get a map view of the cached queries indexed by identifier.
        Specified by:
        getMapView in interface PreparedQueryCache
      • initialize

        public PreparedQuery initialize​(java.lang.String key,
                                        java.lang.Object result)
        Description copied from interface: PreparedQueryCache
        Initialize the cached Prepared Query registered with the given key earlier by the given execution result. If it is not possible to initialize the Prepared Query from the given execution result, then the corresponding key will be marked as invalid for caching.
        Specified by:
        initialize in interface PreparedQueryCache
        Parameters:
        key - the key used during registration
        result - an opaque instance carrying the execution result of the original query.
        Returns:
        the initialized Prepared Query. If it is not possible to initialize the cached, possibly hollow Prepared Query from the given result, return null.
      • invalidate

        public boolean invalidate​(java.lang.String id)
        Description copied from interface: PreparedQueryCache
        Remove the PreparedQuery with the given identifier from this cache.
        Specified by:
        invalidate in interface PreparedQueryCache
      • isCachable

        public java.lang.Boolean isCachable​(java.lang.String id)
        Description copied from interface: PreparedQueryCache
        Affirms if a PreparedQuery can be cached against the given key.
        Specified by:
        isCachable in interface PreparedQueryCache
        Returns:
        Boolean.FALSE if the given key is explicitly marked before as not be cached or matches any of the exclusion patterns. Boolean.TRUE if the given key currently exists in the cache. Otherwise, return null implying this receiver can not determine whether this key can be cached on not.
      • markUncachable

        public PreparedQuery markUncachable​(java.lang.String id,
                                            PreparedQueryCache.Exclusion exclusion)
        Description copied from interface: PreparedQueryCache
        Marks the given key as not amenable to caching. Explicit marking helps to avoid repeated computational cost of determining whether a query can be cached or not.
        Specified by:
        markUncachable in interface PreparedQueryCache
        Parameters:
        id - is the key to be excluded
        exclusion - directs whether exclusion is irreversible or not.
        Returns:
        The value for the given key if it had been cached before. null otherwise.
      • setExcludes

        public void setExcludes​(java.lang.String excludes)
        Description copied from interface: PreparedQueryCache
        Sets one or more exclusion regular expression patterns separated by semicolon. Any existing cache entry whose key matches any of the given pattern will be marked non-cachable in a reversible manner.
        Specified by:
        setExcludes in interface PreparedQueryCache
      • addExclusionPattern

        public void addExclusionPattern​(java.lang.String pattern)
        Adds a pattern for exclusion. Any query cached currently whose identifier matches the given pattern will be marked invalidated as a side-effect.
        Specified by:
        addExclusionPattern in interface PreparedQueryCache
      • lock

        protected void lock​(boolean readOnly)
        Note: Care needs to be taken so that a read lock is never held while requesting a write lock. This will result in a deadlock.
        Parameters:
        readOnly - - If true, a read lock will be acquired. Else a write lock will be acquired.
      • unlock

        protected void unlock​(boolean readOnly)
        Parameters:
        readOnly - - If true, the read lock will be released. Else a write lock will be released.
      • setMaxCacheSize

        public void setMaxCacheSize​(int size)
      • getCacheSize

        public int getCacheSize()
      • startConfiguration

        public void startConfiguration()
        Description copied from interface: Configurable
        Invoked before bean property configuration is begun on this object.
        Specified by:
        startConfiguration in interface Configurable
      • endConfiguration

        public void endConfiguration()
        Description copied from interface: Configurable
        Invoked upon completion of bean property configuration for this object.
        Specified by:
        endConfiguration in interface Configurable