PearlView Counter

By Prashant Gorule

0+ active installationsVersion 1.3.0

Counts post views in Redis and writes them to MySQL only during the hours you choose.

Description

A visit does not update the database. The page prints the current total and, after it has loaded, a tiny request adds one to a Redis counter. A scheduled check later copies those counters into post meta, and only while the clock is inside a window you set.

Default windows, India time (Asia/Kolkata):

  • 3:00 AM to 12:00 PM
  • 3:00 PM to 6:00 PM

Change the time zone, the hours, and how often the check runs under Settings → PearlView Counter.

The total shown at the end of a post is the database value plus anything still waiting in Redis.

Requires a persistent object cache. Redis, via the Redis Object Cache plugin, is the expected setup.

Installation

  1. Upload the plugin zip in Plugins → Add New → Upload Plugin, then activate it.
  2. Install and enable Redis Object Cache so wp-content/object-cache.php is active.
  3. Open Settings → PearlView Counter and confirm the hours.
  4. On a VPS, run real cron every 15 minutes so the 3:00 AM window still fires when the site has no visitors:

    define( ‘DISABLE_WP_CRON’, true );

    */15 * * * * curl -s https://example.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1

FAQ

Will a page view write to MySQL?

No. The view increments Redis. MySQL is updated only inside your write hours, or when an administrator uses “Write to the database now”.

What if Redis restarts before a window?

Pending counts that have not been written yet are lost. Totals already stored in post meta stay.

Does uninstall delete the counts?

No. Settings are removed. The _pearlview_views post meta is left in place.

Changelog

1.0.0

  • First release. Redis counting, scheduled database writes, and a settings screen for the write hours.