////
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
////

= ttl

*Tag:* ttl

[*__since 2.0__*]

[ivysettings.caches.cache.TTL]#Defines a TTL (Time To Live) rule for resolved revision caching.#

When Ivy resolves a dynamic version constraint (like `latest.integration` or a version range), it can store the result of the resolution (like `latest.integration=1.5.1`) for a given time, called TTL. It means that Ivy will reuse this dynamic revision resolution result without accessing the repositories for the duration of the TTL, unless running link:../../use/resolve{outfilesuffix}[resolve] in refresh mode.

This tag lets you define a rule to define a TTL specific to a set of dynamic revision, based on the whole module revision information (organization, module name, revision, ...). The revision considered in the rule is the revision before the resolution (for instance, `latest.integration`) and not the resolved revision (for instance, `1.5.1`).

The rules are evaluated in order, the first matching rule being used to define the TTL. If no rule matches, the cache defaultTTL will be used.

The format used to specify the TTL is of the form:

[source]
----

XXd XXh XXm XXs XXXms

----

Where 'd' stands for days, 'h' for hours, 'm' for minutes, 's' for seconds and 'ms' for milliseconds. Any part of the specification can be omitted, so '12d', '2h 5m' and '1d 5ms' are all valid.

The TTL duration can also be set to `eternal`, in which case once resolved the revision is always use, except when resolving in refresh mode.

Using a 0ms TTL disable resolved revision caching for the given rule.


== Attributes


[options="header",cols="15%,50%,35%"]
|=======
|Attribute|Description|Required
|organisation|the organisation to match to apply the rule.|No, defaults to *
|module|the module's name to match to apply the rule.|No, defaults to *
|revision|the module's revision to match to apply the rule. Note that the version is not resolved when evaluating the rule ('latest.integration', for instance).|No, defaults to *
|_any extra attribute_|an extra attribute to match to apply the rule.|No, defaults to *
|matcher|the link:../../concept{outfilesuffix}#matcher[matcher] to use to match the modules to which the resolver should be applied|No, defaults to exact
|duration|the TTL to apply (see above for format)|Yes
|=======
