Download & Extend

Allow custom times for time based caching

Project:Views
Version:6.x-3.x-dev
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:Unassigned
Status:patch (to be ported)

Issue Summary

Attached is a patch to allow users to set a custom time length for a cache to expire (ie 3 minutes, 1.5 days, etc...). The patch adds a "custom" option to the time drop down select. When "custom" is chosen for either output or results cache's then a text field appears where someone can enter a number of seconds for the cache to last for.

AttachmentSizeStatusTest resultOperations
custom-cach-time.patch4.09 KBIdlePASSED: [[SimpleTest]]: [MySQL] 1,311 pass(es).View details | Re-test

Comments

#1

Status:needs review» needs work

+++ b/plugins/views_plugin_cache_time.incundefined
@@ -17,6 +19,7 @@ class views_plugin_cache_time extends views_plugin_cache {
     $options = array(-1 => t('Never cache')) + $options;
+    $options += array('custom' => t('Custom'));

These lines could probably be combined.

+++ b/plugins/views_plugin_cache_time.incundefined
@@ -25,6 +28,18 @@ class views_plugin_cache_time extends views_plugin_cache {
+      '#description' => 'Length of time in seconds raw query results should be cached',

wrap in t()

+++ b/plugins/views_plugin_cache_time.incundefined
@@ -32,14 +47,40 @@ class views_plugin_cache_time extends views_plugin_cache {
+      '#description' => 'Length of time in seconds rendered HTML output should be cached',

wrap in t()

+++ b/plugins/views_plugin_cache_time.incundefined
@@ -32,14 +47,40 @@ class views_plugin_cache_time extends views_plugin_cache {
+    $custom_fields = array('output_lifespan','results_lifespan');

missing space after comma

+++ b/plugins/views_plugin_cache_time.incundefined
@@ -32,14 +47,40 @@ class views_plugin_cache_time extends views_plugin_cache {
+      if ($form_state['values']['cache_options'][$field] == 'custom' && !is_numeric($form_state['values']['cache_options'][$field . '_custom'])) {

would this need an isset() to prevent notices?

+++ b/plugins/views_plugin_cache_time.incundefined
@@ -32,14 +47,40 @@ class views_plugin_cache_time extends views_plugin_cache {
+    $custom_fields = array('output_lifespan','results_lifespan');

missing space after comma

#2

Status:needs work» needs review

All except the isset() re-rolled here. On the isset() question I believe it's not needed as event the "never cache" options returns a -1 for the first condition of the if() so there is always a value.

AttachmentSizeStatusTest resultOperations
custom-cache-time-1471200-2.patch4.33 KBIdlePASSED: [[SimpleTest]]: [MySQL] 1,311 pass(es).View details | Re-test

#3

Status:needs review» reviewed & tested by the community

Rerolled for git credit for @jalama, and adding full stops to the end of a string. I don't think this needs tests, since its really a UI thing.

The validate works, it gets exported properly, and the UI works.

AttachmentSizeStatusTest resultOperations
views-1471200-3.patch4.41 KBIdlePASSED: [[SimpleTest]]: [MySQL] 1,338 pass(es).View details | Re-test

#4

Version:7.x-3.x-dev» 6.x-3.x-dev
Status:reviewed & tested by the community» patch (to be ported)

Thanks! Committed to 7.x-3.x

nobody click here