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

  • Home
  • SEARCH
  • 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 7752263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:45:17+00:00 2026-06-01T11:45:17+00:00

I am working on an database class based on pdo, the database used is

  • 0

I am working on an database class based on pdo, the database used is a mysql database, but i want to cache the database to get more performance. Would it be a good idea to cache the database in an SQlite in-memory database and do the SELECT’s on this (and update the db on a INSERT, UPDATE, …) db?
But, when i write ” cache = new PDO(‘sqlite:memory’); ” does it create a new one or does it use the existent db? also, if one server hosts multiple websites, how could the use different in-memory databases?

  • 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-06-01T11:45:18+00:00Added an answer on June 1, 2026 at 11:45 am

    Each SQLite in-memory database is connection specific. Even when you open two connections to :memory: within the same process two separate in-memory databases are created. So the answer is that a new database is always created and it never uses an existing database.

    Be cautious to use correct name to create in-memory database. Any other name than :memory: (like :memorry: or memory or /:memory:) doesn’t actually create in-memory database but a regular file based database. This happens silently.

    The performance gain you will get with the suggested caching is likely to be small. If you do selects on MySQL and the computer has plenty of memory, the data is likely to be already in RAM due to OS disk buffering. So adding another layer of RAM in the form of SQLite in-memory database won’t help much.

    The suggested caching leads easily to complex or incorrect caching logic if the system is not read only. If some process does a data update, it must update its cache, update MySQL database and you also have to create some mechanism to tell to other processes that their caches are no longer valid and they must read the data from MySQL. Otherwise your data soon becomes a mess. And think what happens when two processes decide to update same data same time but to different values? You have a conflict.

    To get more performance I would first tune the server and MySQL. If it is not enough I would add a cache like Memcached that is not application process specific but a separate process. Even then you have to be careful to build the application logic in a way that data remains consistent on updates. If you use MySQL only and do correct transactions with InnoDB then MySQL does just that for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I´m rewritting our database class (PDO based), and got stuck at this. I´ve been
at my working place (php only) we have a base class for database abstraction.
I'm currently working on a DNA database class and I currently associate each row
hey everyone... so i'm working on a database design class for university. I've got
I'm currently working on a large implementation of Class::DBI for an existing database structure,
Why is this thing not working? [Database(Name=Relationships_Test)] [Table(Name = Order)] public class Order {
I am working on a web project that is Spring+Hibernate+MySQL based. I am stuck
Here's the scenario, I am working on a web-based application develped used JSP/Servlet technique,
I'm working on some Role-based security for our app and I essentially want to
I am working on a simple standalone desktop application which would generate report based

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.