php-shared-memory | Share variables across multiple PHP apps
kandi X-RAY | php-shared-memory Summary
kandi X-RAY | php-shared-memory Summary
Share variables across multiple PHP apps. This class works like \stdClass, but one instance of SharedMemory can be used simultaneously in several PHP applications. Because this class stores and restores its data every time a property is requested or set, data are always fresh between your applications. And because PHP has a great built-in advisory lock feature, there could be as many applications as you want, there is no concurrent access to the synchronization file.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Opens the file .
- Opens the file .
- Get shared object .
- Locks the object .
- Sets the object .
- Returns the value of a given property .
- Remove a property
- Closes the resource
- Set the connection timeout
- Set the interval interval
php-shared-memory Key Features
php-shared-memory Examples and Code Snippets
Community Discussions
Trending Discussions on php-shared-memory
QUESTION
I want to use shared memory with PHP, like describe here (SimpleSHM). But I wonder how to choose the $systemid
correctly. I have to "hardcode" the number (864, 897
in the examples) in my PHP code so different processes can interact.
But how do I make sure the same id is not used elsewhere (other application, conflicts)? If I generate the id dynamically at runtime I have a chicken / egg problem (how to share the id among my PHP segments using the shared memory).
Ok, I could generate the memory in one place, write the id to a file and read it in other places also using the shared memory. But is this the best way to go?
Code examples:
...ANSWER
Answered 2017-Jan-11 at 19:23If the idea is to have multiple different PHP scripts/libraries/classes all share memory for different purposes, necessitating a number of different $systemid values, I'd strongly suggest creating a constant for each one to give it a name. Define these constants in a file by themselves and then include/require that file in any PHP script that intends to make use of the shared memory.
E.g.:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install php-shared-memory
PHP requires the Visual C runtime (CRT). The Microsoft Visual C++ Redistributable for Visual Studio 2019 is suitable for all these PHP versions, see visualstudio.microsoft.com. You MUST download the x86 CRT for PHP x86 builds and the x64 CRT for PHP x64 builds. The CRT installer supports the /quiet and /norestart command-line switches, so you can also script it.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page