简体   繁体   中英

PHP & PostgreSQL caching sql results

I'm currently working on a affiliate platform for a client of mine. The affiliate platform will deliver banners related to products my client offers on his site. He is expected to have great amount of traffic coming from the affiliate platform (>=500,000 pageloads).

Currently the site is written in PHP and the platform will be also written in PHP. I'm wondering is there an alternative to "EHCache" (Java) in PHP? Or is it possible to cache the database results in some way and refresh them ever X hours for example ?

Also if you have any tips for the affiliate platform - what should I be aware or have in mind when making it etc.

Any help is pretty welcome! :)

Well there is memcached , but it doesn't have disk persistency out-of-the-box. It's a must for PHP applications, which don't have application state and start and die with the client request.

If you're writing PHP scripts for the back-end:

1) PHP scripts aren't long-lived. They leak memory at the best of times. While there are some tricks to reduce leakage and increase the lifespan of your scripts, you'll never be able to completely avoid it so it's better to design your programs to be restartable right from the start.

2) PHP scripts can't do concurrency (which in this context is a term including multithreading and IPC and so on). You will have a hard time writing a script that needs to do two things at once, or two scripts that need to communicate. Prepare to use message queue and locking servers.

3) PHP scripts tend to die ungracefully at the slightest provocation. Use a mechanism to catch and log fatal errors. Design your system to handle abrubt process termination. Code defensively.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM