{@inheritdoc}
This cache decorator always returns a new instance of the payment handler and caches only the contained data.
This is because the handler can potentially have own properties that must not be shared (might even be customer-
specific).
508182
public function getBarePaymentHandler($paymentHandlerId, $languageId = null)
    {
        $cacheKey = $paymentHandlerId;
        if (false === isset($this->cache[$cacheKey])) {
            $paymentHandler = $this->subject->getBarePaymentHandler($paymentHandlerId, $languageId);
            if (null === $paymentHandler) {
                return null;
            }
            $this->cache[$cacheKey] = $paymentHandler->sqlData;

            return $paymentHandler;
        }

        return TdbShopPaymentHandler::getInstanceFromDataRow($this->cache[$cacheKey], $languageId);
    }
886947
@SuppressWarnings("unchecked")
    public static <K,V> Cache<K,V> newNullCache() {
        return (Cache<K,V>) NullCache.INSTANCE;
    }
796847
@Override
    public CacheManagerPeerProvider createCachePeerProvider (
        CacheManager cacheManager, Properties properties)
    {
        if (_instance == null) {
            _instance = new Provider(cacheManager);
        }
        return _instance;
    }
259534
public static function getInstance() {

		if( !isset( self::$instance ) ) {

			self::$instance	= new PaymentProperties();

			self::$instance->init( PaymentGlobal::CONFIG_PAYMENT );
		}

		return self::$instance;
	}
486793
function handleResource( $tpl, &$resourceData, $method, &$extraParameters )
    {
        $path = $resourceData['template-name'];

        $matchKeys = $this->Keys;
        if ( isset( $GLOBALS['eZDesignKeys'] ) )
        {
            $matchKeys = array_merge( $matchKeys, $GLOBALS['eZDesignKeys'] );
            unset( $GLOBALS['eZDesignKeys'] );
            $this->Keys = $matchKeys;
        }
        if ( is_array( $extraParameters ) and
             isset( $extraParameters['ezdesign:keys'] ) )
        {
            $this->mergeKeys( $matchKeys, $extraParameters['ezdesign:keys'] );
        }
        $this->KeyStack[] = $this->Keys;
        $this->Keys = $matchKeys;

        eZDebug::accumulatorStart( 'override_cache', 'Override', 'Cache load' );

        if( !isset( $GLOBALS['eZOverrideTemplateCacheMap'] ) )
        {
            $overrideCacheFile = $this->createOverrideCache();

            if ( $overrideCacheFile )
            {
                include_once( $overrideCacheFile );
            }
        }

        if ( isset( $GLOBALS['eZOverrideTemplateCacheMap'] ) )
        {
            if( isset( $GLOBALS['eZOverrideTemplateCacheMap'][md5( '/' . $path )] ) )
            {
                $cacheMap = $GLOBALS['eZOverrideTemplateCacheMap'][md5( '/' . $path )];
                if ( !is_string( $cacheMap ) and trim( $cacheMap['code'] ) )
                {
                    eval( "\$matchFile = " . $cacheMap['code'] . ";" );
                }
                else
                {
                    $matchFile = $cacheMap;
                }
                $match['file'] = $matchFile;
            }
        }
        else
        {
            $template = "/" . $path;
            $matchFileArray = eZTemplateDesignResource::overrideArray( $this->OverrideSiteAccess );

            $matchFile = $matchFileArray[$template];

            if ( isset( $matchFile['custom_match'] ) )
            {
                $matchFound = false;
                foreach ( $matchFile['custom_match'] as $customMatch )
                {
                    $matchOverride = true;
                    if ( count( $customMatch['conditions'] ) > 0 )
                    {
                        foreach ( array_keys( $customMatch['conditions'] ) as $conditionKey )
                        {
                            // Create special substring match for subtree override
                            if ( $conditionKey == 'url_alias' )
                            {
                                if ( strpos( $matchKeys['url_alias'], $customMatch['conditions'][$conditionKey] ) === 0 )
                                {
                                }
                                else
                                {
                                    $matchOverride = false;
                                }
                            }
                            else if ( isset( $matchKeys[$conditionKey] ) and
                                      isset( $customMatch['conditions'][$conditionKey] ) )
                            {
                                if ( is_array( $matchKeys[$conditionKey] ) )
                                {
                                    if ( !in_array( $customMatch['conditions'][$conditionKey], $matchKeys[$conditionKey] ) )
                                    {
                                        $matchOverride = false;
                                    }
                                }
                                else if ( $matchKeys[$conditionKey] != $customMatch['conditions'][$conditionKey] )
                                {
                                    $matchOverride = false;
                                }
                            }
                            else
                            {
                                $matchOverride = false;
                            }
                        }
                        if ( $matchOverride == true )
                        {
                            $match['file'] = $customMatch['match_file'];
                            $matchFound = true;
                            break;
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        // Default match without conditions
                        $match['file'] = $customMatch['match_file'];
                        $matchFound = true;
                    }
                }
                if ( !$matchFound )
                    $match['file'] = $matchFile['base_dir'] . $matchFile['template'];
            }
            else
            {
                $match['file'] = $matchFile['base_dir'] . $matchFile['template'];
            }
        }
        eZDebug::accumulatorStop( 'override_cache' );
        if ( isset( $match ) )
        {
            $file = $match["file"];

            $matchedKeys = array();
            $usedKeys = array();
            foreach ( $matchKeys as $matchKeyName => $matchKeyValue )
            {
                $usedKeys[$matchKeyName] = $matchKeyValue;
            }
            $extraParameters['ezdesign:used_keys'] = $usedKeys;
            $extraParameters['ezdesign:matched_keys'] = $matchedKeys;
            $tpl->setVariable( 'used', $usedKeys, 'DesignKeys' );
            $tpl->setVariable( 'matched', $matchedKeys, 'DesignKeys' );
            $resourceData['template-filename'] = $file;
            $result = eZTemplateFileResource::handleResourceData( $tpl, $this, $resourceData, $method, $extraParameters );
        }
        else
        {
            $result = false;
        }
        $this->Keys = array_pop( $this->KeyStack );
        return $result;
    }
789921
private Cache<String, Map<String, List<Object>>> getRegisteredServiceCacheInstance(final RegisteredService registeredService,
                                                                                       final CachingPrincipalAttributesRepository repository) {
        val key = buildRegisteredServiceCacheKey(registeredService);
        if (registeredServicesCache.containsKey(key)) {
            return registeredServicesCache.get(key);
        }
        val cache = initializeCache(repository);
        registeredServicesCache.put(key, cache);
        return cache;
    }
339298
public function get_content_handler($handler = null)
	{
		if ( ! empty($this->handler_object))
		{
			return $this->handler_object;
		}

		// When not yet set, use $handler or detect the preferred handler (string = string, otherwise serialize)
		if (empty($this->content_handler) && empty($handler))
		{
			if ( ! empty($handler))
			{
				$this->content_handler = $handler;
			}
			if (is_string($this->contents))
			{
				$this->content_handler = \Config::get('cache.string_handler', 'string');
			}
			else
			{
				$type = is_object($this->contents) ? get_class($this->contents) : gettype($this->contents);
				$this->content_handler = \Config::get('cache.'.$type.'_handler', 'serialized');
			}
		}

		$class = '\\Cache_Handler_'.ucfirst($this->content_handler);
		$this->handler_object = new $class();

		return $this->handler_object;
	}
773927
public function cache($key, callable $cachedCallable, $ttl, callable $onNoStaleCacheCallable = null)
    {
        $value = $this->getValue($key);

        if ($value->hasResult() && !$value->isStale()) {
            return $value->getResult();
        }

        if (!($ttl instanceof Ttl)) {
            $ttl = new Ttl($ttl);
        }

        $lock_acquired = $this->lockManager->acquire($key, $ttl->getLockTtl());

        if (!$lock_acquired) {
            if ($value->hasResult()) { // serve stale if present
                return $value->getResult();
            }

            if (!$onNoStaleCacheCallable) {
                $onNoStaleCacheCallable = $this->onNoStaleCacheCallable;
            }

            if ($onNoStaleCacheCallable !== null) {
                $event = new NoStaleCacheEvent($this, $key, $cachedCallable, $ttl);

                call_user_func($onNoStaleCacheCallable, $event);

                if ($event->hasResult()) {
                    return $event->getResult();
                }
            }
        }

        $result = call_user_func($cachedCallable);

        $this->setResult($key, $result, $ttl);

        if ($lock_acquired) {
            $this->lockManager->release($key);
        }

        return $result;
    }
367238
def cached(func, instance, args, kwargs):
    """"""
    cache = getattr(instance, "__cache", None)
    if cache is None:
        instance.__cache = cache = {}
    try:
        return cache[func]
    except KeyError:
        cache[func] = result = func(*args, **kwargs)
        return result
318722
def nocache(func):
    """"""

    def new_func(*args, **kwargs):
        """No cache Wrapper."""
        resp = make_response(func(*args, **kwargs))
        resp.cache_control.no_cache = True
        return resp

    return update_wrapper(new_func, func)
477970
@Override
	public void cacheResult(CommerceOrder commerceOrder) {
		entityCache.putResult(CommerceOrderModelImpl.ENTITY_CACHE_ENABLED,
			CommerceOrderImpl.class, commerceOrder.getPrimaryKey(),
			commerceOrder);

		finderCache.putResult(FINDER_PATH_FETCH_BY_UUID_G,
			new Object[] { commerceOrder.getUuid(), commerceOrder.getGroupId() },
			commerceOrder);

		finderCache.putResult(FINDER_PATH_FETCH_BY_C_ERC,
			new Object[] {
				commerceOrder.getCompanyId(),
				commerceOrder.getExternalReferenceCode()
			}, commerceOrder);

		commerceOrder.resetOriginalValues();
	}
1311295
@Override
    @SuppressWarnings("unchecked")
    public <T> T get(final Object key, final Callable<T> valueLoader) {
        if (!cache.isEnabled()) {
            LOGGER.warn("Cache {} is disabled. Cannot get {} from cache", cache.getName(), key);
            return loadValue(key, valueLoader);
        }
        final ValueWrapper valueWrapper = get(key);
        if (valueWrapper != null) {
            return (T) valueWrapper.get();
        }
        synchronized (key.toString().intern()) {
            final T value = loadValue(key, valueLoader);
            put(key, value);
            return value;
        }
    }
597877
def cached_method(func):
    
    @functools.wraps(func)
    def wrapper(self, *args):
        if not hasattr(self, "_cache"):
            self._cache = {}
        key = _argstring((func.__name__,) + args)
        if key not in self._cache:
            self._cache[key] = func(self, *args)
        return self._cache[key]
    return wrapper
1196915
private CacheEntry getCacheEntry(Object value, boolean create)
  {

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.entry(
        this,cclass,
        "getCacheEntry",
        new Object[] { value, new Boolean(create), matchCache });

    CacheEntry e = (CacheEntry) matchCache.get(value);
    if (e == null)
    {
      if (create)
      {
        e = new CacheEntry();
        // The following method call may stimulate multiple callbacks to the shouldRetain
        // method if the Hashtable is at the rehash threshold.
        matchCache.put(value, e);
        cacheCreates++;
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      tc.exit(this,cclass, "getCacheEntry", e);

    return e;
  }
91595
function handler (fn, options) {
  /*jshint validthis:true */

  var cache,
      // Extend default options
      settings = extend({}, this.options, options);

  cache = new Cache(fn, settings);
  this.caches.push(cache);
  return cache;
}
368147
def cached(attr):
    
    def decorator(f):
        @functools.wraps(f)
        def decorated(self):
            try:
                return getattr(self, attr)
            except AttributeError:
                value = f(self)
                setattr(self, attr, value)
                return value

        return decorated
    return decorator
876260
def cached_per_instance():
    

    def cache_fun(fun):
        argspec = inspect2.getfullargspec(fun)
        arg_names = argspec.args[1:] + argspec.kwonlyargs  # remove self
        kwargs_defaults = get_kwargs_defaults(argspec)
        cache = {}

        def cache_key(args, kwargs):
            return get_args_tuple(args, kwargs, arg_names, kwargs_defaults)

        def clear_cache(instance_key, ref):
            del cache[instance_key]

        @functools.wraps(fun)
        def new_fun(self, *args, **kwargs):
            instance_key = id(self)
            if instance_key not in cache:
                ref = weakref.ref(self, functools.partial(clear_cache, instance_key))
                cache[instance_key] = (ref, {})
            instance_cache = cache[instance_key][1]

            k = cache_key(args, kwargs)
            if k not in instance_cache:
                instance_cache[k] = fun(self, *args, **kwargs)
            return instance_cache[k]

        # just so unit tests can check that this is cleaned up correctly
        new_fun.__cached_per_instance_cache__ = cache
        return new_fun

    return cache_fun