Cursor rule
.cursor/rules/moodle-performance-optimization.mdc[object Object]
Cursor rules
Quality
50/100
Scores the file, not the repository.Length
289 words
5 headings · 1 code blocksRepository
4
— · pushed 2 days agoLast changed
3 days ago
First indexed 3 days ago.123456# Moodle Performance Optimization78## Purpose9Ensure PHP code follows Moodle performance best practices for optimal execution speed and resource usage.1011## Instructions12When writing PHP code for Moodle, implement these performance optimizations:13141. **Database Queries**: Minimize database calls, use bulk operations when possible152. **Caching**: Use Moodle's caching API (`cache::make()`) for expensive operations163. **Memory Management**: Avoid loading large datasets into memory, use pagination174. **File Operations**: Use Moodle's file API, avoid direct file system access185. **Session Handling**: Minimize session writes, use `$SESSION` sparingly196. **Output Buffering**: Use `ob_start()` and `ob_end_flush()` for large outputs207. **Error Logging**: Use `debugging()` instead of `error_log()` in production218. **Plugin Loading**: Lazy load plugins and dependencies when possible2223## Examples2425```php26<?php27// File: ./includes/performance_example.php2829/**30 * Example of performance-optimized code31 */32function get_optimized_course_data($courseids) {33 global $DB;3435 // Use caching for expensive operations36 $cache = cache::make('core', 'course_data');37 $cachekey = 'course_data_' . md5(serialize($courseids));3839 $cacheddata = $cache->get($cachekey);40 if ($cacheddata !== false) {41 return $cacheddata;42 }4344 // Bulk database query instead of multiple queries45 list($insql, $params) = $DB->get_in_or_equal($courseids, SQL_PARAMS_NAMED);46 $sql = "SELECT c.*, COUNT(e.userid) as enrolled_users47 FROM {course} c48 LEFT JOIN {enrol} e ON c.id = e.courseid49 WHERE c.id $insql50 GROUP BY c.id";5152 $courses = $DB->get_records_sql($sql, $params);5354 // Cache the result for 5 minutes55 $cache->set($cachekey, $courses, 300);5657 return $courses;58}5960/**61 * Efficient file handling62 */63function process_files_efficiently($contextid) {64 $fs = get_file_storage();6566 // Use file iterator for large file sets67 $files = $fs->get_area_files($contextid, 'mod_assign', 'submission');6869 foreach ($files as $file) {70 if ($file->is_directory()) {71 continue;72 }7374 // Process file without loading entire content into memory75 $content = $file->get_content();76 // Process content in chunks if large77 }78}79```8081## Exceptions82- Development environments may use different performance settings83- Debugging may require bypassing some optimizations84
Also in WisdmLabs/moodle-local_edwiserreports-free
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-ajax-and-js-integration.mdc · 4 | Cursor rules | agent-behaviour | 50/100 | 3 days ago | |
| WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-configuration-management.mdc · 4 | Cursor rules | agent-behaviour | 36/100 | 3 days ago | |
| WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-database-patterns.mdc · 4 | Cursor rules | styledatabaseagent-behaviour | 54/100 | 3 days ago | |
| WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-error-handling.mdc · 4 | Cursor rules | agent-behaviour | 50/100 | 3 days ago | |
| WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-events-and-callbacks.mdc · 4 | Cursor rules | agent-behaviour | 50/100 | 3 days ago | |
| WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-file-and-media-handling.mdc · 4 | Cursor rules | agent-behaviour | 36/100 | 3 days ago | |
| WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-internationalization.mdc · 4 | Cursor rules | agent-behaviour | 36/100 | 3 days ago | |
| WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-php-coding-standards.mdc · 4 | Cursor rules | agent-behaviour | 50/100 | 3 days ago | |
| WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-plugin-structure.mdc · 4 | Cursor rules | archagent-behaviour | 54/100 | 3 days ago | |
| WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-scheduled-tasks.mdc · 4 | Cursor rules | agent-behaviour | 50/100 | 3 days ago | |
| WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-security-practices.mdc · 4 | Cursor rules | securityagent-behaviour | 50/100 | 3 days ago | |
| WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-testing-and-quality.mdc · 4 | Cursor rules | testtesting-strategyagent-behaviour | 54/100 | 3 days ago | |
| WisdmLabs/moodle-local_edwiserreports-free.cursor/rules/moodle-web-services-and-api.mdc · 4 | Cursor rules | apiagent-behaviour | 50/100 | 3 days ago |
Diff against .cursor/rules/moodle-ajax-and-js-integration.mdc Diff against .cursor/rules/moodle-configuration-management.mdc Diff against .cursor/rules/moodle-database-patterns.mdc Diff against .cursor/rules/moodle-error-handling.mdc Diff against .cursor/rules/moodle-events-and-callbacks.mdc Diff against .cursor/rules/moodle-file-and-media-handling.mdc Diff against .cursor/rules/moodle-internationalization.mdc Diff against .cursor/rules/moodle-php-coding-standards.mdc Diff against .cursor/rules/moodle-plugin-structure.mdc Diff against .cursor/rules/moodle-scheduled-tasks.mdc Diff against .cursor/rules/moodle-security-practices.mdc Diff against .cursor/rules/moodle-testing-and-quality.mdc Diff against .cursor/rules/moodle-web-services-and-api.mdc
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago |
