Created
October 22, 2012 17:38
-
-
Save zroger/3932853 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c01dcbc1 (Neil Hastings 2012-07-10 13:10:09 -0400 221) function _elc_common_get_cached_value($type, $key, $default_value = '', $new_value = NULL) { | |
c01dcbc1 (Neil Hastings 2012-07-10 13:10:09 -0400 222) $data = &drupal_static(__FUNCTION__, array()); | |
c01dcbc1 (Neil Hastings 2012-07-10 13:10:09 -0400 223) | |
f9c69b8e (Neil Hastings 2012-07-10 18:28:09 -0400 224) $type = str_replace("/", "-", $type); | |
f9c69b8e (Neil Hastings 2012-07-10 18:28:09 -0400 225) $key = str_replace("/", "-", $key); | |
a2ff580f (Tim Cosgrove 2012-07-26 15:10:32 -0700 226) global $theme; | |
19474c32 (Tim Cosgrove 2012-07-30 12:16:28 -0700 227) $request_context = elc_domain_get_request_context(); | |
19474c32 (Tim Cosgrove 2012-07-30 12:16:28 -0700 228) $host = $request_context->host; | |
f9c69b8e (Neil Hastings 2012-07-10 18:28:09 -0400 229) | |
c01dcbc1 (Neil Hastings 2012-07-10 13:10:09 -0400 230) if (isset($new_value)) { | |
c01dcbc1 (Neil Hastings 2012-07-10 13:10:09 -0400 231) $data[$type][$key] = $new_value; | |
19474c32 (Tim Cosgrove 2012-07-30 12:16:28 -0700 232) cache_set("CMS::API::$host::$theme::$type::$key", $new_value); | |
c01dcbc1 (Neil Hastings 2012-07-10 13:10:09 -0400 233) } | |
c01dcbc1 (Neil Hastings 2012-07-10 13:10:09 -0400 234) else { | |
19474c32 (Tim Cosgrove 2012-07-30 12:16:28 -0700 235) if ($cache_data = cache_get("CMS::API::$host::$theme::$type::$key")) { | |
c01dcbc1 (Neil Hastings 2012-07-10 13:10:09 -0400 236) $data[$type][$key] = $cache_data->data; | |
c01dcbc1 (Neil Hastings 2012-07-10 13:10:09 -0400 237) } | |
c01dcbc1 (Neil Hastings 2012-07-10 13:10:09 -0400 238) else { | |
c01dcbc1 (Neil Hastings 2012-07-10 13:10:09 -0400 239) $data[$type][$key] = $default_value; | |
19474c32 (Tim Cosgrove 2012-07-30 12:16:28 -0700 240) cache_set("CMS::API::$host::$theme::$type::$key", $default_value); | |
c01dcbc1 (Neil Hastings 2012-07-10 13:10:09 -0400 241) } | |
c01dcbc1 (Neil Hastings 2012-07-10 13:10:09 -0400 242) } | |
c01dcbc1 (Neil Hastings 2012-07-10 13:10:09 -0400 243) | |
c01dcbc1 (Neil Hastings 2012-07-10 13:10:09 -0400 244) return $data[$type][$key]; | |
c01dcbc1 (Neil Hastings 2012-07-10 13:10:09 -0400 245) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment