Plugin Directory

Changeset 2156157


Ignore:
Timestamp:
09/13/2019 01:34:51 PM (6 years ago)
Author:
runcloud
Message:

fixed flush redis object prefix:options:alloptions

Location:
runcache-purger/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • runcache-purger/trunk/languages/runcachepurger.pot

    r2155285 r2156157  
    55msgstr  "Project-Id-Version: RunCache Purger 1.0.0\n"
    66        "Report-Msgid-Bugs-To: https://runcloud.io\n"
    7         "POT-Creation-Date: 2019-09-12 14:23+0800\n"
     7        "POT-Creation-Date: 2019-09-13 21:30+0800\n"
    88        "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    99        "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    3838msgstr  ""
    3939
    40 #: runcache-purger.php:544 runcache-purger.php:663
     40#: runcache-purger.php:546 runcache-purger.php:665
    4141msgid   "Settings"
    4242msgstr  ""
    4343
    44 #: runcache-purger.php:678
     44#: runcache-purger.php:680
    4545msgid   "Clear Cache this Post"
    4646msgstr  ""
    4747
    48 #: runcache-purger.php:689
     48#: runcache-purger.php:691
    4949msgid   "Clear Cache this URL"
    5050msgstr  ""
    5151
    52 #: runcache-purger.php:699 views/settings.php:194
     52#: runcache-purger.php:701 views/settings.php:197
    5353msgid   "Clear All Cache"
    5454msgstr  ""
    5555
    56 #: runcache-purger.php:1124
     56#: runcache-purger.php:1130
    5757msgid   "Failed to purge cache."
    5858msgstr  ""
    5959
    60 #: runcache-purger.php:1131
     60#: runcache-purger.php:1137
    6161msgid   "Purging cache was successful."
    6262msgstr  ""
    6363
    64 #: runcache-purger.php:1133
     64#: runcache-purger.php:1139
    6565msgid   "Purging redis object cache was successful."
    6666msgstr  ""
    6767
    68 #: runcache-purger.php:1138
     68#: runcache-purger.php:1144
    6969#, php-format
    7070msgid   "Purging method not implement. Status Code %s"
    7171msgstr  ""
    7272
    73 #: runcache-purger.php:1143
     73#: runcache-purger.php:1149
    7474msgid   "Redis server not connected."
    7575msgstr  ""
    7676
    77 #: runcache-purger.php:1145
     77#: runcache-purger.php:1151
    7878msgid   "Failed to purge redis object cache."
    7979msgstr  ""
    8080
    81 #: runcache-purger.php:1148
     81#: runcache-purger.php:1154
    8282msgid   "Purging method not implement."
    8383msgstr  ""
    8484
    85 #: runcache-purger.php:1153
     85#: runcache-purger.php:1159
    8686#, php-format
    8787msgid   "Failed to purge cache. Status Code %s"
     
    173173msgstr  ""
    174174
    175 #: views/settings.php:147
     175#: views/settings.php:150
    176176msgid   "Hostname"
    177177msgstr  ""
    178178
    179 #: views/settings.php:150
     179#: views/settings.php:153
    180180msgid   "Port"
    181181msgstr  ""
    182182
    183 #: views/settings.php:153
     183#: views/settings.php:156
    184184msgid   "Key Prefix"
    185185msgstr  ""
    186186
    187 #: views/settings.php:160
     187#: views/settings.php:163
    188188msgid   "Purge Object Cache"
    189189msgstr  ""
    190190
    191 #: views/settings.php:164
     191#: views/settings.php:167
    192192msgid   "Automatically clean redis object cache when any purge action was "
    193193        "triggered."
    194194msgstr  ""
    195195
    196 #: views/settings.php:171
     196#: views/settings.php:174
    197197msgid   "Enable Object Cache"
    198198msgstr  ""
    199199
    200 #: views/settings.php:175
     200#: views/settings.php:178
    201201msgid   "Enable this option to allow this plugin handle redis object cache."
    202202msgstr  ""
    203203
    204 #: views/settings.php:189
     204#: views/settings.php:192
    205205msgid   "Purge Actions"
    206206msgstr  ""
    207207
    208 #: views/settings.php:198
     208#: views/settings.php:201
    209209msgid   "Clear Homepage Cache"
    210210msgstr  ""
    211211
    212 #: views/settings.php:202
     212#: views/settings.php:205
    213213msgid   "Clear Content Cache"
    214214msgstr  ""
    215215
    216 #: views/settings.php:206
     216#: views/settings.php:209
    217217msgid   "Clear Archives Cache"
    218218msgstr  ""
    219219
    220 #: views/settings.php:210
     220#: views/settings.php:213
    221221msgid   "Clear Redis Cache"
    222222msgstr  ""
  • runcache-purger/trunk/readme.txt

    r2154386 r2156157  
    11=== RunCache Purger (Alpha) ===
    2 Tags: runcloud, nginx, cache, redis, fastcgi
     2Contributors: fikrizaman,kamaroolkarim,hadian90
     3Tags: nginx, cache, redis, fastcgi
    34Requires at least: 5.1
    45Tested up to: 5.2
  • runcache-purger/trunk/runcache-purger.php

    r2155908 r2156157  
    55 * Plugin URI:      https://wordpress.org/plugins/runcache-purger/
    66 * Description:     This plugin will purge RunCloud.io NGINX fastcgi, Proxy Cache and Redis Object Cache.
    7  * Version:         1.4.0
     7 * Version:         1.5.0
    88 * Author:          RunCloud
    99 * Author URI:      https://profiles.wordpress.org/runcloud/
     
    6464
    6565    // version
    66     private static $version      = '1.4.0';
    67     private static $version_prev = '1.3.0';
     66    private static $version      = '1.5.0';
     67    private static $version_prev = '1.4.0';
    6868
    6969    // later
     
    443443    {
    444444
    445         self::flush_object(true);
    446 
    447445        $file = RUNCACHE_PURGER_PATH_VENDOR . 'object-cache.php';
    448446        if (!file_exists($file)) {
     
    487485    private static function uninstall_dropin()
    488486    {
    489         self::flush_object(true);
    490 
    491487        $file_dropin = self::get_dropin_file();
    492488        if (file_exists($file_dropin) && defined('RUNCACHE_PURGER_DROPIN')) {
     
    16741670
    16751671    /**
     1672     * __shutdown.
     1673     */
     1674    private static function __shutdown() {
     1675        add_action('shutdown', function() {
     1676            wp_cache_flush(0);
     1677            wp_cache_delete('alloptions', 'options');
     1678
     1679            if ( function_exists('wp_cache_self_remove') && defined('RUNCACHE_PURGER_DROPIN') ) {
     1680                wp_cache_self_remove();
     1681            }
     1682        });
     1683    }
     1684
     1685    /**
    16761686     * activate.
    16771687     */
     
    16881698    {
    16891699        self::force_site_deactivate_plugin();
    1690         // should clear everything, but there is a bug where options:alloptions keys were fetched and stored when deactivating
    1691         self::flush_object(true);
    1692         self::uninstall_dropin();
     1700        self::__shutdown();
    16931701    }
    16941702
     
    16991707    {
    17001708        self::uninstall_options();
    1701         self::uninstall_dropin();
     1709        self::__shutdown();
    17021710    }
    17031711
     
    17191727        self::uninstall_options();
    17201728        self::install_options();
    1721         self::install_dropin();
    17221729    }
    17231730
  • runcache-purger/trunk/vendor/object-cache.php

    r2155285 r2156157  
    6262}
    6363
    64 function wp_cache_delete($key, $group = '', $time = 0)
    65 {
    66     global $wp_object_cache;
    67 
    68     return $wp_object_cache->delete($key, $group, $time);
     64function wp_cache_delete($key, $group = '')
     65{
     66    global $wp_object_cache;
     67
     68    return $wp_object_cache->delete($key, $group);
    6969}
    7070
     
    143143}
    144144
    145 function wp_cache_redis_stats_array()
    146 {
    147     global $wp_object_cache;
    148 
    149     return $wp_object_cache->stats_array();
     145function wp_cache_self_remove()
     146{
     147    @unlink(__FILE__);
    150148}
    151149
     
    426424    }
    427425
    428     private function sanitize_key_prefix($prefix) {
    429         if ( preg_match('/[\'\/~`\!@#\$%\^&\*\(\)_\-\+=\{\}\[\]\|;:"\<\>,\.\?\\\]/', $prefix) ) {
    430             return md5($prefix);
    431         }
    432 
    433         return $prefix;
    434     }
    435 
    436426    public function flush($delay = 0)
    437427    {
     
    447437        if ($this->redis_status()) {
    448438            $salt = defined('RUNCACHE_PURGER_DROPIN_PREFIX') ? trim(RUNCACHE_PURGER_DROPIN_PREFIX) : null;
    449             if ( !empty($salt) ) {
    450                 $salt = $this->sanitize_key_prefix($salt);
    451             }
    452 
    453439            $selective = defined('WP_REDIS_SELECTIVE_FLUSH') ? WP_REDIS_SELECTIVE_FLUSH : null;
    454440
     
    732718    }
    733719
    734     public function stats_array() {
    735         return [
    736             'status' => ( $this->redis_status() ? 'Connected' : 'Not Connected' ),
    737             'client' => $this->redis_client,
    738             'hit' => $this->cache_hits,
    739             'miss' => $this->cache_misses,
    740         ];
    741     }
    742 
    743720    public function build_key($key, $group = 'default')
    744721    {
     
    748725
    749726        $salt = defined('RUNCACHE_PURGER_DROPIN_PREFIX') ? trim(RUNCACHE_PURGER_DROPIN_PREFIX) : '';
    750         if ( !empty($salt) ) {
    751             $salt = $this->sanitize_key_prefix($salt);
    752         }
    753 
    754727        $prefix = in_array($group, $this->global_groups) ? $this->global_prefix : $this->blog_prefix;
    755 
    756728        return "{$salt}{$prefix}:{$group}:{$key}";
    757729    }
Note: See TracChangeset for help on using the changeset viewer.