Changeset 976 for trunk/xcache.c
- Timestamp:
- 2012-07-14T06:44:18+02:00 (10 months ago)
- File:
-
- 1 edited
-
trunk/xcache.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/xcache.c
r975 r976 2683 2683 } 2684 2684 /* }}} */ 2685 static void xc_clear(long type, xc_cache_t *cache TSRMLS_DC) /* {{{ */ 2686 { 2687 xc_entry_t *e, *next; 2688 int entryslotid, c; 2689 2690 ENTER_LOCK(cache) { 2691 for (entryslotid = 0, c = cache->hentry->size; entryslotid < c; entryslotid ++) { 2692 for (e = cache->entries[entryslotid]; e; e = next) { 2693 next = e->next; 2694 xc_entry_remove_unlocked(type, cache, entryslotid, e TSRMLS_CC); 2695 } 2696 cache->entries[entryslotid] = NULL; 2697 } 2698 } LEAVE_LOCK(cache); 2699 } /* }}} */ 2685 2700 /* {{{ xcache_admin_operate */ 2686 2701 typedef enum { XC_OP_COUNT, XC_OP_INFO, XC_OP_LIST, XC_OP_CLEAR } xcache_op_type; … … 2698 2713 } 2699 2714 2700 if (optype == XC_OP_COUNT) { 2701 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &type) == FAILURE) { 2702 return; 2703 } 2704 } 2705 else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &type, &id) == FAILURE) { 2706 return; 2715 switch (optype) { 2716 case XC_OP_COUNT: 2717 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &type) == FAILURE) { 2718 return; 2719 } 2720 break; 2721 case XC_OP_CLEAR: 2722 id = -1; 2723 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &type, &id) == FAILURE) { 2724 return; 2725 } 2726 break; 2727 default: 2728 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &type, &id) == FAILURE) { 2729 return; 2730 } 2707 2731 } 2708 2732 … … 2747 2771 } LEAVE_LOCK(cache); 2748 2772 break; 2773 2749 2774 case XC_OP_CLEAR: 2750 { 2751 xc_entry_t *e, *next; 2752 int entryslotid, c; 2753 2754 if (!caches || id < 0 || id >= size) { 2755 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cache not exists"); 2756 RETURN_FALSE; 2775 if (!caches || id < -1 || id >= size) { 2776 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cache not exists"); 2777 RETURN_FALSE; 2778 } 2779 2780 if (id == -1) { 2781 for (id = 0; id < size; ++id) { 2782 xc_clear(type, caches[id] TSRMLS_CC); 2757 2783 } 2758 2759 cache = caches[id]; 2760 ENTER_LOCK(cache) { 2761 for (entryslotid = 0, c = cache->hentry->size; entryslotid < c; entryslotid ++) { 2762 for (e = cache->entries[entryslotid]; e; e = next) { 2763 next = e->next; 2764 xc_entry_remove_unlocked(type, cache, entryslotid, e TSRMLS_CC); 2765 } 2766 cache->entries[entryslotid] = NULL; 2767 } 2768 } LEAVE_LOCK(cache); 2769 xc_gc_deletes(TSRMLS_C); 2770 } 2784 } 2785 else { 2786 xc_clear(type, caches[id] TSRMLS_CC); 2787 } 2788 2789 xc_gc_deletes(TSRMLS_C); 2771 2790 break; 2772 2791 … … 2797 2816 } 2798 2817 /* }}} */ 2799 /* {{{ proto array xcache_clear_cache(int type, int id)2818 /* {{{ proto array xcache_clear_cache(int type, [ int id = -1 ]) 2800 2819 Clear cache by id on specified cache type */ 2801 2820 PHP_FUNCTION(xcache_clear_cache)
Note: See TracChangeset
for help on using the changeset viewer.

