Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6778001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:12:53+00:00 2026-05-26T16:12:53+00:00

For fun i am writing a fastcgi app. Right now all i do is

  • 0

For fun i am writing a fastcgi app. Right now all i do is generate a GUID and display it at the top of the page then make a db query based on the url which pulls data from one of my existing sites.

I would like to attempt to cache everything on the page except for the GUID. What is a good way of doing that? I heard of but never used redis. But it appears its a server which means its in a seperate process. Perhaps an in process solution would be faster? (unless its not?)

What is a good solution for page caching? (i’m using C++)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:12:54+00:00Added an answer on May 26, 2026 at 4:12 pm

    Your implementation sounds like you need a simple key-value caching mechanism, and you could possibly use a container like std::unordered_map from C++11, or its boost cousin, boost::unordered_map. unordered_map provides a hash table implementation. If you needed even higher performance at some point, you could also look at Boost.Intrusive which provides high performance, standard library-compatible containers.

    If you roll your cache with the suggestions mentioned, a second concern will be expiring cache entries, because of the possibility your cached data will grow stale. I don’t know what your data is like, but you can choose to implement a caching strategy like any of these:

    • after a certain time/number of uses, expire a cached entry
    • after a certain time/number of uses, expire the entire cache (extreme)
    • least-recently used – there’s a stack overflow question concerning this: LRU cache design

    Multithreaded/concurrent access may also be a concern, though as suggested in the link above, a possibility would be to lock the cache on access rather than worry about granular locking.


    Now if you’re talking about scaling, and moving up to multiple processes, and distributing server processes across multiple physical machines, the simple in-process caching might not be the way to go anymore (everyone could have different copies of data at any given time, inconsistency of performance if some server has cached data but others don’t).

    That’s where Redis/Memcached/Membase/etc. shine – they are built for scaling and for offloading work from a database. They could be beaten out by a database and in-memory cache in performance (there is latency, after all, and a host of other factors), but when it comes to scaling, they are very useful and save load from a database, and can quickly serve requests. They also come with features cache expiration (implementations differ between them).

    Best of all? They’re easy to use and drop in. You don’t have to choose redis/memcache from the outset, as caching itself is just an optimization and you can quickly replace the caching code with using, say, an in-memory cache of your own to using redis or something else.

    There are still some differences between the caching servers though – membase and memcache distribute their data, while redis has master-slave replication.

    For the record: I work in a company where we use memcached servers – we have several of them in the data center with the rest of our servers each having something like 16 GB of RAM allocated completely to cache.

    edit:

    And for speed comparisons, I’ll adapt something from a Herb Sutter presentation I watched long ago:

    • process in-memory -> really fast
    • getting data from a local process in-memory data -> still really fast
    • data from local disk -> depends on your I/O device, SSD can be fast, but mechanical drives are glacial
    • getting data from remote process (in-memory data) -> fast-ish, and your cache servers better be close
    • getting data from remote process (disk) -> iceberg
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an app that displays fun-facts (and the source they are from).
I'm writing a basic little forums web app (for fun and to sharpen the
I'm writing a quick little money tracking rails app for fun that allows a
I'm writing some code (just for fun so far) in Python that will store
I'm writing a basic planet viewer OpenGL Perl application, just for fun. I have
I am beginning some experimentation in writing a kernel and having fun doing it.
I am building a fun little app to determine if I should bike to
I'm implementing a simplistic JIT compiler in a VM I'm writing for fun (mostly
I'm writing my own compiler for the fun of it xD. It's compiling to
I'm writing a simple clipboard manager in wxpython for fun and profit and I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.