 .../Core/Cache/UncacheableDependencyTrait.php      | 40 ++++++++++++++++++++++
 .../Plugin/views/filter/HistoryUserTimestamp.php   | 11 ++----
 .../src/CacheableTestDomainObject.php              | 22 ++----------
 .../modules/views/src/Plugin/views/sort/Random.php | 24 ++-----------
 4 files changed, 48 insertions(+), 49 deletions(-)

diff --git a/core/lib/Drupal/Core/Cache/UncacheableDependencyTrait.php b/core/lib/Drupal/Core/Cache/UncacheableDependencyTrait.php
new file mode 100644
index 0000000..a2f00e8
--- /dev/null
+++ b/core/lib/Drupal/Core/Cache/UncacheableDependencyTrait.php
@@ -0,0 +1,40 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Core\Cache\UncacheableDependencyTrait.
+ */
+
+namespace Drupal\Core\Cache;
+
+/**
+ * Trait to implement CacheableDependencyInterface for uncacheable objects.
+ *
+ * Use this for objects that are never cacheable.
+ *
+ * @see \Drupal\Core\Cache\CacheableDependencyInterface
+ */
+trait UncacheableDependencyTrait {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCacheContexts() {
+    return [];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCacheTags() {
+    return [];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCacheMaxAge() {
+    return 0;
+  }
+
+}
diff --git a/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php b/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php
index 9abfe56..4b5e261 100644
--- a/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php
+++ b/core/modules/history/src/Plugin/views/filter/HistoryUserTimestamp.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\history\Plugin\views\filter;
 
+use Drupal\Core\Cache\UncacheableDependencyTrait;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\views\Plugin\views\filter\FilterPluginBase;
 
@@ -22,6 +23,8 @@
  */
 class HistoryUserTimestamp extends FilterPluginBase {
 
+  use UncacheableDependencyTrait;
+
   // Don't display empty space where the operator would be.
   var $no_operator = TRUE;
 
@@ -98,12 +101,4 @@ public function adminSummary() {
     }
   }
 
-  /**
-   * {@inheritdoc}
-   */
-  public function getCacheMaxAge() {
-    // This filter depends on the current time and therefore is never cacheable.
-    return 0;
-  }
-
 }
diff --git a/core/modules/system/tests/modules/early_rendering_controller_test/src/CacheableTestDomainObject.php b/core/modules/system/tests/modules/early_rendering_controller_test/src/CacheableTestDomainObject.php
index 64f6345..088d18f 100644
--- a/core/modules/system/tests/modules/early_rendering_controller_test/src/CacheableTestDomainObject.php
+++ b/core/modules/system/tests/modules/early_rendering_controller_test/src/CacheableTestDomainObject.php
@@ -8,28 +8,10 @@
 namespace Drupal\early_rendering_controller_test;
 
 use Drupal\Core\Cache\CacheableDependencyInterface;
+use Drupal\Core\Cache\UncacheableDependencyTrait;
 
 class CacheableTestDomainObject extends TestDomainObject implements CacheableDependencyInterface {
 
-  /**
-   * {@inheritdoc}
-   */
-  public function getCacheContexts() {
-    return [];
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function getCacheTags() {
-    return [];
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function getCacheMaxAge() {
-    return 0;
-  }
+  use UncacheableDependencyTrait;
 
 }
diff --git a/core/modules/views/src/Plugin/views/sort/Random.php b/core/modules/views/src/Plugin/views/sort/Random.php
index 944ac7f..f9f9e49 100644
--- a/core/modules/views/src/Plugin/views/sort/Random.php
+++ b/core/modules/views/src/Plugin/views/sort/Random.php
@@ -8,6 +8,7 @@
 namespace Drupal\views\Plugin\views\sort;
 
 use Drupal\Core\Cache\CacheableDependencyInterface;
+use Drupal\Core\Cache\UncacheableDependencyTrait;
 use Drupal\Core\Form\FormStateInterface;
 
 /**
@@ -17,6 +18,8 @@
  */
 class Random extends SortPluginBase implements CacheableDependencyInterface {
 
+  use UncacheableDependencyTrait;
+
   /**
    * {@inheritdoc}
    */
@@ -33,25 +36,4 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
     $form['order']['#access'] = FALSE;
   }
 
-  /**
-   * {@inheritdoc}
-   */
-  public function getCacheMaxAge() {
-    return 0;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function getCacheContexts() {
-    return [];
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function getCacheTags() {
-    return [];
-  }
-
 }
