Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clean memcache
- http://stackoverflow.com/questions/3724838/will-restarting-apache-clear-my-memcache-contents
- =====================================
- telnet localhost 11211
- flush_all
- =====================================
- http://stackoverflow.com/questions/8164376/how-to-cache-a-php-generated-xml-file-in-drupal
- /**
- * Implement hook_menu()
- * to define path for our xml file.
- */
- function mymodule_menu() {
- $items = array();
- $items['map.xml'] = array(
- 'title' => 'Map xml',
- 'page callback' => 'map_get_xml',
- 'access arguments' => TRUE,
- 'type' => MENU_CALLBACK
- );
- return $items;
- }
- /**
- * Your custom function for xml file.
- */
- function map_get_xml() {
- $cache = cache_get('your-cache-id');
- $xml = $cache->data;
- if (!$xml) {
- $xml = ... // perform your code to generate your XML
- cache_set('your-cache-id', $xml);
- }
- drupal_set_header("Content-Type:text/xml");
- print $xml;
- exit();
- }
- ==========================================
- <?php
- function MY_MODULE_cron() {
- $content = MY_MODULE_xml();
- file_put_contents($_SERVER['DOCUMENT_ROOT'] . file_directory_path() . '/MY_FILE.XML', $content);
- }
- function MY_MODULE_xml() {
- $page_content = '<?xml version="1.0" encoding="UTF-8"?>
- ...';
- return $page_content;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement