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 6757639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:40:37+00:00 2026-05-26T13:40:37+00:00

I have a caching class that has a flat file driver, meaning you can

  • 0

I have a caching class that has a flat file driver, meaning you can cache arbitrary data to a flat file using a key and expiration time, then retrieve this data using the same key.

Expire duration must be set with the setCache method in order to work with other drivers (as opposed to having an expiration duration argument on the getCache method, even though this would make determining whether the cache has expired much easier, as I could just compare it to the files last modification time).

Currently I prepend a timestamp (+ expire duration) to the beginning of the file. When a user tries to getCache related to that file, the method opens the file and strips off the first line to get this timestamp. It then uses that timestamp to figure out whether or not that cache has expired. This is not very efficient obviously.

I recently came accross a PHP function touch(), which allows me to set a file’s last modification time to an arbitrary value. This sounds awesome because it would allow me to (instead of the above mentioned method of figuring out if the cache has expired), set the file’s last modification time to some point in the future. I can then check this time to see if the cache has expired yet.

I really REALLY want to be able to use this. My application is distributed however, and since this function works with the environment, I am not sure if I should trust this function to work as expected accross the board on different systems. Does anyone have any information or resources about the compatability of this function?

  • 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-26T13:40:38+00:00Added an answer on May 26, 2026 at 1:40 pm

    The biggest issue you are going to run into here is permissions. If the user your php script (actually its apache) creates the file, he will own the file and be able to make changes as desired. This will only work assuming that the apache user has the permissions to create that file inside the folder ( check the directory permissions).

    You can also create the file your self and set the owner to be the user that apache runs php scripts as (can be found in the httpd.conf file)

    https://www.php.net/manual/en/function.touch.php — documentation for touch

    http://drupal.org/node/34023 –describes the exact situation you are running into and goes more into permissions.

    http://www.faqs.org/docs/securing/chap29sec245.html — talks about modifying the httpd.conf file

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

Sidebar

Related Questions

I have a asp.net web forms app that uses System.Web.Caching.Cache to cache xml data
I have a class (in C++), call it Data , that has thousands of
I have a class that access web services. It can optionally cache results. So
I have a Video entity that has multiple Genres, public class Video { public
I have a few models that contain static data, and I'm trying to cache
I have a file caching system for a php application. if a file needs
I have application that makes different queries with different results so the caching in
We have an application that uses Hibernate's 2nd level caching to avoid database hits.
I have a WCF service that is using a custom UsernamePasswordValidator. The validator needs
We have a Rails app that has some pages that are available to all

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.