Search code examples
catomicg-wan

How to implment atomic operation in C in G-WAN


I want to count views for a web page, while I am using G-WAN and C. I am not really so familiar with them. I am using Intel 64-bit processor. I have searched for the topic and still get no idea, can anyone help me? Thank you.


Solution

  • I want to count views for a web page, while I am using G-WAN and C

    Fine, there are several options:

    • a G-WAN servlet
    • a G-WAN connection handler
    • a G-WAN content-type handler

    ...and your code can use different ways depending on your needs (listed in order of speed and memory efficiency):

    • a global atomic variable attached to a G-WAN persistent pointer
    • a global G-WAN KV store attached to a G-WAN persistent pointer
    • a system shared memory segment (it will survive a server stop)
    • an in-memory or disk-based database (SQLite, etc.)
    • a DB KV store or server (Memcached, Redis, mySQL, etc.)
    • etc.

    You can even use a mix of these and use a fast (in-memory) method that is periodically stored to disk.

    It really depends on your needs (is the counter tracking one single page? is it fetched 10,000 times per second, 1 million times? etc.).