Question

To grab the inode of a file in PHP, you can use this:

$fs = stat($file);
echo $fs['ino'];

The problem with this is EVERYWHERE says it's slow and you should avoid it. So the question becomes what's the fast(er) way to do it?

Was it helpful?

Solution

You could use fileinode() but you should run benchmarks if you think it is slow.

OTHER TIPS

I think you should benchmark and take a look at what you are doing to determine if stat() is the slowest part of your code. Stating 1 file on each request on a server that gets about 100 hits/day is not a problem. Stating every file could be a problem when you have to eek out a few more requests a second.

You can avoid stating the same file repeatedly by caching the results via memcached, apc or some other in-memory caching system.

Premature optimization is the root of all evil. - Donald Knuth

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top