ãµã€ãã®ããŒãžã¯ãµã€ãºã倧ãããªã£ãŠãããã³ã³ãã³ããéåæã«èªã¿èŸŒããšããåé¡ãçããŠããŸãã ããããã¡ã€ã³ããŒãžã®èªã¿èŸŒã¿åŸã«ç°¡åã«ç»åãèªã¿èŸŒãããã®ã©ã€ãã©ãªãããå ŽåãããŒãžã®HTMLéšåïŒãããã¯ïŒã®éåæèªã¿èŸŒã¿ã§ã¯ããã¹ãŠãã¯ããã«è€éã«ãªããŸãã ããšãã°ããµã€ãã®ããã©ãŒãã³ã¹ãæãªãããšãªãDrupalã§éåæãããã¯èªã¿èŸŒã¿ãå®è£ ããã«ã¯ããã£ãã·ã³ã°ã®ä»çµã¿ã䜿çšæ¹æ³ãæé©åæ¹æ³ãç解ããå¿ èŠããããŸãã ãã®åŸãèšç»ãããèšç»ãé 延èªã¿èŸŒã¿ãã«åŸã£ãŠããµã€ãã®ãããã¯ãèªã¿èŸŒã¿ãŸãã
Drupal Cacheã®æŠèŠ
Drupalã®ãã£ãã·ã¥ã¯ãæå°ã®ã·ã¹ãã ãªãœãŒã¹ãšæ倧é床ã§ãŠãŒã¶ãŒã«è¿ãããšãã§ããé »ç¹ã«èŠæ±ãããããŒã¿ãæ ŒçŽããäžéãããã¡ãŒã§ãã ãã®ãããã¡ã¯ãããŒã¿ããŒã¹å ã®ããŒãã«ãããŒããã£ã¹ã¯äžã®ããŒã¿ãã¡ã€ã«ããŸãã¯ãããã¯ãŒã¯ãžã£ãŒãã«ããŒã¿ãŠã§ã¢ããŠã¹å ã®ããŒãšå€ã®ã»ããã§ãã Drupalã§Webã¢ããªã±ãŒã·ã§ã³ããã£ãã·ã¥ããããã«PHPãšçµ±åã§ããæ å ±ãä¿åããããã®ãªãã·ã§ã³ãé©ããŠããŸãã
Drupalã§ãã£ãã·ã¥ã䜿çšãã1ã€ã®äŸã¯ãã¡ãã¥ãŒãã£ãã·ã¥ã§ãã ã»ãšãã©ã®å Žåãã¡ãã¥ãŒã¯ãµã€ãã®é »ç¹ã«å€æŽãããéšåã§ã¯ãããŸããã ãŠãŒã¶ãŒããµã€ãã®æ°ããããŒãžã«ã¢ã¯ã»ã¹ãããšãã«è¡šç€ºããã¡ãã¥ãŒããæ¯ååæ§ç¯ããïŒãã¹ãŠã®ã¢ã€ãã ãååŸããçžäºã«äŸåãããã³ãã¬ãŒãã«è¡šç€ºããïŒã¡ãã¥ãŒã¯æå³ããããŸããã ããã«ãããã1000ã¢ã€ãã ã®ã«ã¿ãã°ã®ã¡ãã¥ãŒã§ããå Žåãåºåçšã«éåžžã«é·ãæéåæ§ç¯ã§ããŸãã ãªããŠãŒã¶ãŒãåŸ ãããã®ã§ããïŒ ãããã£ãŠãDrupalã¯ã管çè ãæå®ããæéãäžåºŠäœæããã¡ãã¥ãŒããã£ãã·ã¥ãããã£ãã·ã¥ãããŠãŒã¶ãŒã«è¡šç€ºããŸããããã«ãããã¡ãã¥ãŒãåæ§ç¯ããé·æéã®æäœãåé¿ã§ããŸãã
Drupalã«ã¯ïŒåºæ¬ã¢ãžã¥ãŒã«ã«ïŒçµã¿èŸŒã¿ãã£ãã·ã¥ãå«ãŸããŠããã/ admin / settings / performanceã§æ§æã§ããŸãã éçºã®ããããã«æ°ããæ©èœãè¿œå ãããšãïŒãã³ãã¬ãŒããŸãã¯ã¢ãžã¥ãŒã«ã®ãããã§ãã£ãŠãïŒãå®æçã«ã¯ãªãŒãã³ã°ããããšãå¿ããªãã§ãã ããã
ãã£ãã·ã¥ã¯ããã€ãã®æ¹æ³ã§ã¯ãªã¢ã§ããŸãã
- / admin / settings / performanceããŒãžã®ãClear Cacheããã¿ã³ã䜿çšããŸã
- admin_menuã¢ãžã¥ãŒã«ãã€ã³ã¹ããŒã«ãã巊端ã®ã¿ãã§[ãã¹ãŠã®ãã£ãã·ã¥ããã©ãã·ã¥]ãéžæããŸã
- ãªã³ã¯ã空ã®ãã£ãã·ã¥ãïŒãã£ãã·ã¥ã®ã¯ãªã¢ïŒã䜿çšããŠããããã¯Develãããã¯ïŒã¢ãžã¥ãŒã«DevelïŒ
- DrushïŒdrush cache-clear themeã³ãã³ããå®è¡ããïŒããŒããã£ãã·ã¥ã®ã¿ãã¯ãªã¢ãããŸãïŒ
- ããã°ã©ã ã§drupal_rebuild_themeé¢æ°ãåŒã³åºãããšã«ããïŒããŒããã£ãã·ã¥ã®ã¿ãã¯ãªã¢ãããŸãïŒ
Drupalãã£ãã·ã¥-ãã£ãã·ã¥ã»ã°ã¡ã³ã
Drupalãã£ãã·ã¥ã¯ãåäžã®å Žæã«ä¿åãããã®ã§ã¯ãªããã»ã°ã¡ã³ãåãããŸãã ããã©ã«ãã§ã¯ãåãã£ãã·ã¥ã»ã°ã¡ã³ãã¯åå¥ã®ããŒãã«ãšããŠããŒã¿ããŒã¹ã«ä¿åãããŸãã ããã«ãããé »ç¹ã«æŽæ°ããããã£ãã·ã¥ã»ã°ã¡ã³ãããMemcachedãBoostãªã©ã®ä»ã®ãã£ãã·ã¥ã¹ãã¬ãŒãžã·ã¹ãã ã«ç§»åã§ããŸãã ããã«ããããã£ãã·ã¥ã®æäœã®ããã©ãŒãã³ã¹ãåäžããŸããããŒã¿éãå°ãªãå Žåãã¬ã³ãŒãã®æäœãé«éã«ãªããŸãã ããã«ãç¹å®ã®ã¢ã¯ã·ã§ã³ã§ã¯ããã£ãã·ã¥ãéšåçã«ã¯ãªã¢ïŒã»ã°ã¡ã³ãåïŒã§ããŸãã
Drupalã«ã¯ããŸããŸãªãã£ãã·ã¥ã»ã°ã¡ã³ãããããŸãã ãã£ãã·ã¥ã»ã°ã¡ã³ãã¯ãããŒãžã§ã³7.XXãš6.XXã§é¡äŒŒããŠããŸãïŒ
1. {cache} -å ±æãã£ãã·ã¥ã¹ãã¬ãŒãžã®ã»ã°ã¡ã³ãã ããã«ã¯åé¡ã§ããªãããŒã¿ãå«ãŸããŠãããããããã®æ°ãããã£ãã·ã¥ã»ã°ã¡ã³ããäœæããŠãæå³ããããŸããã
2. {cache_block}-Blockã¢ãžã¥ãŒã«ããªã³ã«ãªã£ããšãã«è¿œå ãããŸããïŒã«ãŒãã«ã«å«ãŸããŠããŸãïŒã DrupalããŒãé åãããŒããããšããã®é åã®ãã¹ãŠã®ãããã¯ã«ããŒã¿ãããŒããããå¿ èŠã«å¿ããŠãhook_block_viewïŒïŒããã¯åŒã³åºããã¹ãããããŠããã£ãã·ã¥ãããããã¯ãæ§ç¯ãŸãã¯è¡šç€ºãããŸãã hook_node_accessïŒïŒã䜿çšããŠãããªã¢ã«ã¢ã¯ã»ã¹ãæäœããã¢ãžã¥ãŒã«ãæå¹ã«ãªã£ãŠããå Žåããããã¯ã®ãã£ãã·ã¥ãç¡å¹ã«ãªã£ãŠããããšãèæ ®ãã䟡å€ããããŸãã ãŸããhook_block_infoïŒïŒã䜿çšããŠããã°ã©ã ã§ãããã¯ãäœæããå Žåããããã¯ã®ãã£ãã·ã¥ãã©ã¡ãŒã¿ãŒãå¶åŸ¡ã§ããããšãç¥ã£ãŠããå¿ èŠããããŸãïŒè©³çŽ°ã«ã€ããŠã¯ãããã¥ã¡ã³ããåç §ããŠãã ããïŒã
3. {cache_filter}-Filterã¢ãžã¥ãŒã«ã¯ããã£ã«ã¿ãŒã«ãã£ãŠåŠçãããããã¹ãã®ãã£ãã·ã¥ãä¿åããããã®ç¬èªã®ããŒãã«ãäœæããŸãã ãã£ã«ã¿ãè€éã«ãªãã»ã©ãããã¹ãåŠçã«ããå€ãã®ããã»ããµæéãè²»ããããŸãã ãããã£ãŠãå¯èœãªéããcheck_markupïŒïŒãžã®ãã¹ãŠã®åŒã³åºãã¯ãã£ãã·ã¥ãããŸãã {cache_filter}ããŒãã«ã®ãã£ãã·ã¥IDã¯ãèŠåformat_nameïŒlanguageïŒtext hashã«åŸã£ãŠåéãããŸãã
4. {cache_form} -ãµã€ããé«éåããããã«ä»ã®ãã£ãã·ã¥ããŒã¿ãä¿åãããŠããå Žåããã®ãã£ãã·ã¥ã¯ããã©ãŒãã³ã¹ã«äžå圱é¿ããŸããã Forms APIã䜿çšããŠæ§ç¯ããããã©ãŒã ã¯ãè匱æ§ã®èŠ³ç¹ããå®å šã«å®å šã§ããå¿ èŠããããŸãã ãã©ãŒã ãäœæããããã³ã«ã{cache_form}ã»ã°ã¡ã³ãã«ä¿åãããŸãã å€ãã®ãã©ãŒã ãšèšªåè ãããå Žåãcronãå®è¡ããŠ1ã2æéããšã«ãã£ãã·ã¥ãã¯ãªã¢ããªããšã{cache_form}ã«ã¯å°è±¡çãªãµã€ãºã«æ¡åŒµããããããã£ããããŸãã
5. {cache_menu} -ã¡ãã¥ãŒã¢ãžã¥ãŒã«ããªã³ã«ãªããšãªã³ã«ãªããã€ã³ã¿ãŒãã§ãŒã¹ãä»ããŠäœæããããã¹ãŠã®ã¡ãã¥ãŒããã®ãªã³ã¯ã®ãªããžããªã«ãªããŸãã ãã£ãã·ã¥IDã¯ã次ã®ã«ãŒã«ãªã³ã¯ã«åŸã£ãŠäœæãããŸããmenu_nameïŒtree-dataïŒlanguageïŒãã©ã¡ãŒã¿ãŒã®ããã·ã¥ã
6. {cache_page} -å¿åãŠãŒã¶ãŒã®ãã£ãã·ã¥ããŒãžããŒã¿ãä¿åããŸãã çŸåšã®ããŒãžã®ãã£ãã·ã¥ãèŠã€ãã£ãå Žåãhook_bootïŒïŒãšhook_exitïŒïŒã®2ã€ã®ããã¯ã®ã¿ãåŒã³åºãããŸãã æ®ãã®ããã¯ïŒhook_initïŒïŒãªã©ãå«ãïŒã¯ã¹ããããããŸãã ããã¯ããå¿åãŠãŒã¶ãŒã®ããŒãžããã£ãã·ã¥ããããã§ãã¯ããã¯ã¹ã«ããããµã€ãã®ããã©ãŒãã³ã¹èšå®ã»ã¯ã·ã§ã³ïŒadmin / config / development / performanceïŒã§æå¹ã«ãªã£ãŠãããã£ãã·ã¥ã§ãã
7. {cache_update} -æŽæ°ãããŒãžã£ãŒã¢ãžã¥ãŒã«ã¯ãã®ã»ã°ã¡ã³ããè¿œå ããŸãã å«ãŸããŠããã¢ãžã¥ãŒã«ã®ãã¹ãŠã®ãªãªãŒã¹ã®ããŒã¿ãä¿åããŸãã
DrupalããŒãžã§ã³7.XXïŒããŒãžã§ã³6.XXã§ã¯ãªãïŒã§äœ¿çšå¯èœãªãã£ãã·ã¥ã»ã°ã¡ã³ã ïŒ
1. {cache_path} -ã·ã¹ãã ãã¹å ã®ãšã€ãªã¢ã¹ã®æ€çŽ¢ãé«éåããããã«ãã·ã¹ãã ãã¹ãšãã®ãšã€ãªã¢ã¹éã®å¯Ÿå¿ãä¿åããŸãã
2. {cache_image} -Imageã¢ãžã¥ãŒã«ã«ãã£ãŠäºçŽãããŠãããç»åã®ããŸããŸãªæäœã«é¢ããæ å ±ã®ã¹ãã¬ãŒãžãšããŠäœ¿çšã§ããŸãã
3. {cache_bootstrap}-Drupalã®èµ·åæã«åæåãããããŒã¿ãä¿åãããã£ãã·ã¥ã»ã°ã¡ã³ãã
4. {cache_field} -ãã®ã»ã°ã¡ã³ãã«ã¯ããã¹ãŠã®ãã£ãŒã«ãã®ããŒã¿ãæ ŒçŽãããŸãã ãã£ãã·ã¥IDã¯ãã«ãŒã«ãã£ãŒã«ãentity_typeïŒentity_idã«ãã£ãŠåœ¢æãããŸãã
ãµãŒãããŒãã£ã®ã¢ãžã¥ãŒã«ã¯ãç¬èªã®ãã£ãã·ã¥ã»ã°ã¡ã³ããäœæããããšãã§ããŸãã ããšãã°ããããã³ã°ãããã¢ãžã¥ãŒã«ã®ã»ã°ã¡ã³ããl10n_updateãtokenãviewsïŒ
- cache_hacked
- cache_l10n_update
- cache_token
- cache_views
- cache_views_data
ã«ãŒãã«ãšã¯é¢ä¿ãªããCToolsã¢ãžã¥ãŒã«ã«ãã£ãŠäœæãããCtoolsãªããžã§ã¯ããã£ãã·ã¥ã«èšåãã䟡å€ããããŸãã CToolsãªããžã§ã¯ããã£ãã·ã¥ã¯ãçŸåšç·šéäžã®å€§ããªãªããžã§ã¯ããä¿åããããã®ã¹ããŒã¹ãæäŸãããã£ãã·ã¥ã»ã°ã¡ã³ãã§ãã ããšãã°ãå€æŽããããã¥ãŒã®ãã£ãã·ã¥ã¯ãViewsã¢ãžã¥ãŒã«ã«ä¿åãããåã«CToolsãªããžã§ã¯ããã£ãã·ã¥ã«ä¿åãããŸãã ä»ã®ãã£ãã·ã¥ã»ã°ã¡ã³ããšã¯ç°ãªããè¿œå ã®ãã£ãŒã«ãsidïŒã»ãã·ã§ã³IDïŒ-çŸåšã®ãŠãŒã¶ãŒã»ãã·ã§ã³ã®èå¥åããããŸãã ãã®ãããã§ãå€æŽãããããŒã¿ã¯ãªããžã§ã¯ããå€æŽãããŠãŒã¶ãŒã«ã®ã¿è¡šç€ºãããŸãã ãã®ã»ã°ã¡ã³ãã«ã¯æå¹æéãã£ãŒã«ãããªããã€ã³ã¿ãŒãã§ãŒã¹ãä»ããŠãã£ãã·ã¥ãã¯ãªã¢ãããŠãåé€ãããŸãããããã®ã»ã°ã¡ã³ããã1é±éåã®ãã£ãã·ã¥ãåé€ããããšãCronã«ãã£ãŠ1æ¥ã«1åã¯ãªã¢ãããŸãã
ããŒãžã®ã©ã€ããµã€ã¯ã«
ãŠãŒã¶ãŒãWebãµãŒããŒããããŒãžãèŠæ±ãããšã次ã®ããšãçºçããŸãïŒããšãã°ãDrupalããŒãžã§ã³7.XXïŒïŒ
Drupalã«ãŒãã«ã¯ã次ã®ãã©ã¡ãŒã¿ãŒã®ããããã§èµ·åãããŸãã
- DRUPAL_BOOTSTRAP_CONFIGURATION ïŒæ§æã®ã¿ãåæåããŸãã
- DRUPAL_BOOTSTRAP_PAGE_CACHE ïŒãã£ãã·ã¥ã¬ã€ã€ãŒãåæåããŸãã
- DRUPAL_BOOTSTRAP_DATABASE ïŒããŒã¿ããŒã¹å±€ãåæåããŸãã
- DRUPAL_BOOTSTRAP_VARIABLES ïŒå¯å€å±€ãåæåããŸãã
- DRUPAL_BOOTSTRAP_SESSION ïŒã»ãã·ã§ã³ã䜿çšããäœæ¥ã®åæåã
- DRUPAL_BOOTSTRAP_PAGE_HEADER ïŒããããŒå±€ãåæåããŸãã
- DRUPAL_BOOTSTRAP_LANGUAGE ïŒããŒãžã®èšèªã¬ã€ã€ãŒãåæåããŸãã
- DRUPAL_BOOTSTRAP_FULL ïŒDrupalãå®å šã«ããŒãããŸãã ãŸããå ¥åãããããŒã¿ããã§ãã¯ããã³ä¿®æ£ããæ©èœãè¿œå ããŸãã
詳现ã«ã€ããŠã¯ãincludesãã©ã«ããŒã«ããbootstrap.incãã¡ã€ã«ã®drupal_bootstrapïŒïŒé¢æ°ãåç §ããŠãã ããã
drupal_bootstrapïŒïŒãDRUPAL_BOOTSTRAP_FULLãã©ã¡ãŒã¿ãŒãæå®ããŠå®è¡ãããå ŽåïŒ
- ã·ã¹ãã é¢æ°ãã¡ã€ã«ã®æ¥ç¶ã
- ãã¹ãŠã®ã¬ã€ã€ãŒãšãã©ã€ããªèšå®ã®åæåã
- å«ãŸãããã¹ãŠã®ã¢ãžã¥ãŒã«ã®ãã¡ã€ã«ã®æ¥ç¶ã
- Drupalã§ãã¹ãšãã®ãšã€ãªã¢ã¹ãæäœããããã®å€æ°ãšã·ã¹ãã é¢æ°ã®åæåã
- å«ãŸããã¹ãã³ã®åæåã
- ããã¯ãmodule_invoke_allïŒïŒãå®è¡ããããšã«ããè¡ãããŸãã Drupalã¢ãžã¥ãŒã«ãããŒãããŠå¯Ÿè©±ããããã®APIãå®è£ ããçŸåšå«ãŸããŠããã¢ãžã¥ãŒã«ã®ãã¹ãŠã®ããã¯ãç»é²ããŸãã
ãã®åŸãmenu_execute_active_handlerïŒïŒé¢æ°ãåŒã³åºãããŸããããã¯ãããã²ãŒã·ã§ã³ã¡ãã¥ãŒãå®çŸ©ããããŒãžèŠæ±ããµã€ãäžã®ãã¹ã«ãã€ã³ããããé¢æ°åŒã³åºãã«å€æããŸãã ãŸãããã®é¢æ°å ã§åŒã³åºããè¡ãããŸãã
- drupal_deliver_html_pageïŒïŒé¢æ°ãããŒãžããŒã¿ãHTMLãšããŠãŠãŒã¶ãŒã®ãã©ãŠã¶ãŒã«è¿ããŸãã ãã®é¢æ°å ã§drupal_renderïŒïŒé¢æ°ãåŒã³åºãããŸãããã®é¢æ°ã¯ãããŒã¿ã衚瀺ããã ãã§ãªãããã³ãã¬ãŒããšã³ãžã³ã䜿çšããŠããŒãžãåçæãã代ããã«ãããŒã¿ããã£ãã·ã¥ã»ã°ã¡ã³ãã®1ã€ã«ä¿åããŠããããååŸããŸãã
- drupal_page_footerïŒïŒé¢æ°ãå¿ èŠã«å¿ããŠããŒãžãã£ãã·ã¥ïŒãcache_pathããšãcache_bootstrapãïŒãèšå®ããã¢ãžã¥ãŒã«ãhook_exitïŒïŒã«ããããŒãžã®ã¯ããŒãºã«å¿çã§ããããã«ããŸãã Cronã¯å¿ èŠã«å¿ããŠããã«èµ·åãããŸãã
äžè¬çãªå ŽåïŒ
- å¿ èŠãªå€æ°ãšé¢æ°ã¯ãã¹ãŠåæåãããŸãã
- ãã®URLïŒ{cache_page}ïŒã«ãã£ãã·ã¥ããããã©ããã確èªããŸãã ååšããå Žåã圌ã¯æ»ããããã§ãªãå Žåããããªãã¢ã¯ã·ã§ã³ãå®è¡ãããŸãã
- ãã£ãŒã«ãïŒ{cache_field}ïŒãã³ã³ãã³ãïŒ{cache_filter}ïŒãã¡ãã¥ãŒïŒ{cache_menu}ïŒããããã¯ïŒ{cache_block}ïŒãç»åïŒ{cache_image}ïŒããã³ãšã€ãªã¢ã¹ïŒ{cache_path}ïŒã®ãã£ãã·ã¥ããããã©ããããã§ãã¯ããŸãã ãã£ãã·ã¥ã䜿çšã§ããªãå Žåãå¿ èŠãªããŒã¿ãååŸããŠåŠçãããã£ãã·ã¥ã«ä¿åããæäœãå®è¡ãããŸãã åä¿¡ããããŒã¿ã¯ããŒãæ©èœã«è»¢éãããŸãã
- ããŒãé¢æ°ã¯ããŒãžãäœæããæå®ãããURLïŒ{cache_page}ïŒã§ãã£ãã·ã¥ããŸãã
- ããŒã¿ããŠãŒã¶ãŒã«è¿ãããŸãã
Drupal 7.Xã䜿çšããããã°ã©ãã³ã°ãã£ãã·ã¥
ãã£ãã·ã¥ãæäœããæãäžè¬çãªæ¹æ³ã¯ãcache_seté¢æ°ã䜿çšããŠãéçºããã¢ãžã¥ãŒã«ã®ããŒã¿ããã£ãã·ã¥ã«ä¿åããããšã§ãã cache_geté¢æ°ã䜿çšããŠãããããæœåºããã ãã§ãªãã
<?php // , : my_module_data. if ($cache = cache_get('my_module_data')) { // , . return $cache->data; } else { // , . $my_data = ' '; // : my_module_data : {cache}. cache_set('my_module_data', $my_data, 'cache'); // . return $my_data; } ?>
次ã®ããããã®é¢æ°ãåŒã³åºãããšã«ãããmy_module_dataãšããååã®ãã£ãã·ã¥ããŒã¿ãã¯ãªã¢ã§ããŸãã
<?php // // ( ). cache_clear_all(); // {my_module_data}. cache_clear_all('*', 'my_module_data', TRUE); // {my_module_data} , // Cache ID c 'my_module'. cache_clear_all('my_module', 'my_module_data', TRUE); ?>
ããã¯ãããŒãžã®ãµã€ã管çè ã®ã€ã³ã¿ãŒãã§ãŒã¹ïŒ example.com/admin/config/development/performanceïŒãã[ãã£ãã·ã¥ã®ã¯ãªã¢]ãã¿ã³ãã¯ãªãã¯ããŠå®è¡ã§ããŸãã
example.com/admin/config/development/performanceããŒãžã§[ãã£ãã·ã¥ã®ã¯ãªã¢]ãã¿ã³ãã¯ãªãã¯ããããšã«äŸåããã«ãããŒã¿ãäžå®æéãã£ãã·ã¥ããå Žåã¯ãããŒã¿ããã£ãã·ã¥ããç§æ°ã ãè¿œå ã®ãã©ã¡ãŒã¿ãŒãcache_seté¢æ°ã«è¿œå ããå¿ èŠããããŸãã
<?php cache_set('my_module_data', $my_data, 'cache', time() + 360); ?>
Drupalã§ã¯ãããŒã¿ã¹ãã¬ãŒãžçšã«ç¬èªã®ãã£ãã·ã¥ã»ã°ã¡ã³ããäœæã§ããŸãã ãã®ã¢ãžã¥ãŒã«ãäœæããŸãããïŒmymoduleã ãããè¡ãã«ã¯ããµã€ããã£ã¬ã¯ããªïŒ./sites/default/modulesã«ãã©ã«ããŒmymoduleãäœæããŸãã ãã®äžã«ãå 容ãå«ãã¢ãžã¥ãŒã«èšè¿°ãã¡ã€ã«mymodule.infoãäœæããŸãã
name = My module description = " ." core = 7.x version = 7.x-1.x-dev files[] = mymodule.module
ãŸããhook_schemaïŒïŒã䜿çšããŠããã£ãã·ã¥ã»ã°ã¡ã³ãã®ããŒã¿ãæ ŒçŽããæ°ããããŒãã«ãäœæããmymodule.installãã¡ã€ã«ãäœæããŸãã
<?php /** * Implements hook_schema(). */ function mymodule_schema() { // : {cache}. // // . $schema['mymodule'] = drupal_get_schema_unprocessed('system', 'cache'); $schema['mymodule']['description'] = 'Cache table stores some example data.'; return $schema; }
äœæããã»ã°ã¡ã³ãã瀺ãcache_seté¢æ°ã®äœ¿çšãéå§ããåã®æåŸã®ã¹ãããã¯ãmymodule.moduleãã¡ã€ã«ãäœæããexample.com/admin/config/development/performanceã®[ãã£ãã·ã¥ã®ã¯ãªã¢]ãã¿ã³ãã¯ãªãã¯ãããšãã£ãã·ã¥ãèªåçã«ãªã»ããããããšã§ãã
<?php /** * Implements hook_flush_caches(). */ function mymodule_flush_caches() { // . return array('mymodule'); }
example.com/admin/modulesããŒãžã§ã¢ãžã¥ãŒã«ãæå¹ã«ãããã®åŸãããšãã°ãã¢ãžã¥ãŒã«ã«ãã£ãŠäœæããããã£ãã·ã¥ã®ç¬èªã®ã»ã°ã¡ã³ãã«æ¬¡ã®ããŒã¿ãä¿åããŸãã
<?php cache_set('my_module_data', ' ', 'mymodule'); ?>
ããŸãç¥ãããŠããªãé¢æ°cache_is_emptyããããæå®ãããååã§ããŒã¿ããã£ãã·ã¥ã«ä¿åãããŠãããã©ããã調ã¹ãããšãã§ããŸãã
<?php cache_is_empty('my_module'); ?>
sub_module cache_exampleãmoduleïŒexamplesã®ããŒãžïŒ www.drupal.org/project/examplesã§ãDrupal 6.Xããã³8.Xã®ãã£ãã·ã¥ã®æäœæ¹æ³ãåžžã«ç¢ºèªã§ããŸãã
ããŒã¿ããŒã¹ãããã£ãã·ã¥ãåé€ãã
ã»ã°ã¡ã³ããã£ãã·ã¥ã¯ãããšãã°ãMemcachedãŸãã¯Redisã«ç§»è¡ã§ããŸãã
ååºèã«ã¯ç¬èªã®ãµããŒã¿ãŒãããŸãã Evgeniy MaslovskiyïŒSpleshkaãwww.drupal.org / u / spleshka ïŒã¯èšäºã®å·çãæ¯æŽããMemcachedã®æ¯æè ã§ããã圌ã®ãµã€ãã§ã¯MemcachedãšDrupalã®çµ±åã«ã€ããŠè©³ãã説æããŠããŸãã 圌ã説æããMemcachedãšã®çµ±åã¢ãžã¥ãŒã«ã«ã¯ãä»ã®ãœãªã¥ãŒã·ã§ã³ã«åãè¿œå ã®å©ç¹ããããŸãããã£ãã·ã¥ãåä¿¡ãããšãã«ããŒã¿ããŒã¹ãžã®æ¥ç¶ããã€ãã¹ããä»ã®ã¢ãžã¥ãŒã«ã®hook_exitïŒïŒããã³hook_boostrapïŒïŒåŒã³åºãããã€ãã¹ããŸãã
ãã®èšäºã§ã¯ãRedisã§ã®ãã£ãã·ã¥ã¬ã³ããªã³ã°ã«ã€ããŠèª¬æããŸããããã¯ãMemcachedãããç°¡åãªã»ããã¢ããã§æ°ã«å ¥ã£ãŠããŸãã äž¡æ¹ã®ãªããžããªã®é床ã®æ¯èŒãã¹ãã¯ãå¥ã®èšäºã§æ€èšãããŸãã
ãµãŒããŒã®Redisèšå®ã¯ã€ã³ã¿ãŒãããã§ç¢ºèªã§ããŸãã Drupalçµ±åã¢ãžã¥ãŒã«ãwww.drupal.org/project/redisããããŠã³ããŒãããã/ sites / all / modulesãã£ã¬ã¯ããªãŒã«è§£åããŸãã ãã®åŸãDrupalã®./sites/default/settings.phpèšå®ãã¡ã€ã«ã«å€æŽãå ããŠã次ã®è¡ãè¿œå ããŸãã
$conf['redis_client_interface'] = 'PhpRedis'; $conf['redis_client_host'] = $relationships['redis'][0]['host']; $conf['redis_client_port'] = $relationships['redis'][0]['port']; // PHP Redis. $conf['redis_client_interface'] = 'PhpRedis'; $conf['cache_backends'][] = 'sites/all/modules/redis/redis.autoload.inc'; $conf['cache_default_class'] = 'Redis_Cache'; // {cache_form} . $conf['cache_class_cache_form'] = 'DrupalDatabaseCache'; // : {mymodule} // Redis. $conf['cache_class_mymodule'] = 'Redis_Cache';
ã¢ãžã¥ãŒã«ãã©ã«ããŒå ã®README.txtãã¡ã€ã«ãèªãããšãå¿ããªãã§ãã ããããã¹ãŠã®ã¢ãžã¥ãŒã«èšå®ãèšè¿°ãããŠããããã§ãã
ããã¯ã©ãã«é©çšã§ããŸããïŒ
説æããç¥èã®çšéã®1ã€ã¯ããµã€ãã®ããŒã¿ã®äžéšãã¡ã€ã³ããŒãžã®ããŒãåŸã«ããŒãããããããã¯ã«åé€ããããšã§ããããã«ããããµã€ãã®ããŒããé«éåããããµã€ãå šäœã®äœæ¥ãé«éåãããŸã ãã®èšäºã䜿çšããŠãAjax Blocksã¢ãžã¥ãŒã«ãããŒã¹ãšããŠãHigh-performance JavaScriptã³ãŒã«ããã¯ãã³ãã©ãŒã¢ãžã¥ãŒã«ãšçµ±åããRedisã®ãªããžããªã«ããŒã¿ãã£ãã·ã¥ãé 眮ããã ãã§ãã
ãããã«
ãã®èšäºã«ã¯ãã³ãã¥ããã£ã«ãã£ãŠäœæããã www.drupal.orgã§ãã¹ããããŠããå€æ°ã®ãã£ãã·ã³ã°ã¢ãžã¥ãŒã«ã®èª¬æã¯å«ãŸããŠããŸããã§ãã ã èšäºãæ°ã«å ¥ã£ãããæ祚ããŠããã次ã®èšäºã§Drupal 8ã®ãã£ãã·ã¥ã®ã¬ãã¥ãŒãšãã圢ã§ããŒãã¹ãå«ããããã«ããŸãããŸããSilexãšAngularJSã®ããã³ããšã³ãã§RedisãŸãã¯Elasticsearchãã£ãã·ã¥ã®ã¹ãã¬ãŒãžãšããŠDrupalã䜿çšããããšãæ€èšããŸãã