Skip to main content
Update formatting
Source Link

Perhaps it would be useful to look at the linux function with the same name.the manual page for the linux function with the same name:

flockflock() places advisory locks only; given suitable permissions on a file, a process is free to ignore the use of flockflock() and perform I/O on the file.1

You asked:

Should using LOCK_SH in read() allow for multiple simultaneous reads?

From the linux manual page for flock:

LOCK_SH

Place a shared lock. More than one process may hold a shared lock for a given file at a given time.


Should the check() method handle the case where the directory does exist but is not writable (i.e. using is_writable())? And what if the user is not able to update permissions?

The flock() function returns true on success or false on failure 2 so perhaps it would be useful to use those values to determine if subsequent operations should be attempted.

While using file_put_contents() function were you using LOCK_EX in the $flags (i.e. 3rd ) parameter)? If not, that might be a technique to simplify the write function.

I can’t think of a reason the write function would need to return the data to be written- is that imperative for your code?

Perhaps it would be useful to look at the linux function with the same name.

flock() places advisory locks only; given suitable permissions on a file, a process is free to ignore the use of flock() and perform I/O on the file.1

You asked:

Should using LOCK_SH in read() allow for multiple simultaneous reads?

From the linux manual page for flock:

LOCK_SH

Place a shared lock. More than one process may hold a shared lock for a given file at a given time.


Should the check() method handle the case where the directory does exist but is not writable (i.e. using is_writable())? And what if the user is not able to update permissions?

The flock() function returns true on success or false on failure 2 so perhaps it would be useful to use those values to determine if subsequent operations should be attempted.

While using file_put_contents() function were you using LOCK_EX in the $flags (i.e. 3rd ) parameter)? If not, that might be a technique to simplify the write function.

I can’t think of a reason the write function would need to return the data to be written- is that imperative for your code?

Perhaps it would be useful to look at the manual page for the linux function with the same name:

flock() places advisory locks only; given suitable permissions on a file, a process is free to ignore the use of flock() and perform I/O on the file.1

You asked:

Should using LOCK_SH in read() allow for multiple simultaneous reads?

From the linux manual page for flock:

LOCK_SH

Place a shared lock. More than one process may hold a shared lock for a given file at a given time.


Should the check() method handle the case where the directory does exist but is not writable (i.e. using is_writable())? And what if the user is not able to update permissions?

The flock() function returns true on success or false on failure 2 so perhaps it would be useful to use those values to determine if subsequent operations should be attempted.

While using file_put_contents() function were you using LOCK_EX in the $flags (i.e. 3rd ) parameter)? If not, that might be a technique to simplify the write function.

I can’t think of a reason the write function would need to return the data to be written- is that imperative for your code?

Source Link

Perhaps it would be useful to look at the linux function with the same name.

flock() places advisory locks only; given suitable permissions on a file, a process is free to ignore the use of flock() and perform I/O on the file.1

You asked:

Should using LOCK_SH in read() allow for multiple simultaneous reads?

From the linux manual page for flock:

LOCK_SH

Place a shared lock. More than one process may hold a shared lock for a given file at a given time.


Should the check() method handle the case where the directory does exist but is not writable (i.e. using is_writable())? And what if the user is not able to update permissions?

The flock() function returns true on success or false on failure 2 so perhaps it would be useful to use those values to determine if subsequent operations should be attempted.

While using file_put_contents() function were you using LOCK_EX in the $flags (i.e. 3rd ) parameter)? If not, that might be a technique to simplify the write function.

I can’t think of a reason the write function would need to return the data to be written- is that imperative for your code?