2008/05/16

The Labs.Com WebCounter
Last update 1999/08/26
The Labs - Design & Functionality For The Net

Just Another Web-Counter

  1. Introduction
  2. Download
  3. Usage
  4. MyDB Detail
WebCounter
1. Introduction
This is just another web-counter as a small case-study to implement a simple counter using MyDBase.

The main difficulty with web-counter which store server side is locking the counter-file, when you have heavy load it could happen two counters access (read & write) the same counter-file where you store the counter, and this may cause reset of the counter or missing hit. Since most sites have low volume this is often not considered. This counter certainly works also properly under heavy load since it uses the client-server way so there is no locking problem at all.

WebCounter
2. Download

mywebcount.cgi and get one of the background GIFs:
50x13

60x16

60x16

60x16

64x20

according your own web-design. If you don't reference any background GIF the counter appears without it.

WebCounter
3. Usage

 <img src="mywebcount.cgi?count=name"> 

Add a new user in passwd of MyDBase:

 counter:yourpassword 

and enter the password in the mywebcount.cgi file.

WebCounter
4. MyDB Detail

The counter is implemented with perl using GD.pm and TieMyDB.pm which makes the entire source quite small.

Using

 $count = $db{...}++; 

creates one get and one put for the database.
using

 $count = ++$db{...}; 

creates one get one put and additional a get when you check with the mydbd log-files. For that reason, $db{}++ is more economical, despite it's not logical correct, as the actual counter is 1 more than displayed.

                                                                                                                                   

Last update 1999/08/26

All Rights Reserved - (C) 1997 - 2008 by The Labs.Com

Top of Page

The Labs.Com