couchdb-php | PHP package to interact with CouchDB using Memcached | Database library
kandi X-RAY | couchdb-php Summary
kandi X-RAY | couchdb-php Summary
[couchdb] is amazing and easy-to-use nosql document-oriented database. due to the origin of http and the fact that couchdb uses rest api, the best way to interact with couchdb is events-using webserver, such as [node.js] with [couchdb-memcached] or [cradle] module installed. node.js can save the data between the requests of different users and that’s why it doesn’t need the cache layer. however couchdb rest api allows everyone to interact with couchdb. in case of php we do not have such an opportunity as node.js/cradle can afford, so memcached server here is a cache layer between couchdb and your php-written app. couchdb documents and views have etags which uniquely represent the documents. if the document changes, its etag changes too. so memcached stores documents' etags and lets us make few requests to couchdb server if we have fetched the valid documents before
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Get database meta information
- Get CouchDB data
- Update a database
- Insert a database
- Delete a database record
- Create the curl handler
- Generates a unique identifier .
- Encode memcache key .
- Url encode a key
couchdb-php Key Features
couchdb-php Examples and Code Snippets
Community Discussions
Trending Discussions on couchdb-php
QUESTION
I am writing a php script to interact with a CouchDb server. The script reads an SQL database and creates documents and PUTs them on the server. Each script runs every 5 minutes and puts about 2000 documents (creates and updates).
Running sync, this takes about 3 minutes to PUT all the docs. In a test I did using node and promises, I found CouchDb can handle 100 asnyc puts at the same time and respond back in only slightly more time than it took to do a single document. I want to utilize this feature in PHP instead.
I have available, php 5.3 and php 7.0.10 on a Windows server.
How do I do this asnyc?
My first thought was using the pclose(popen()) trick, but that spawns a new process each time, and even if I restrict this to 100 docs at a time (my tests show up to 700 at a time is doable), that would still results in 6 scripts creating and recreating total of 600 new processes every 100/2000 docs every 5 minutes, or a total of 12,000 processes created and run every 5 minutes. I don't think Windows can handle that.
My second idea was to set up a basic node script to handle it, with PHP creating and formatting the data, writing to a file, and passing the file to a node script to process async and report back to PHP using exec. But I am hoping to find a pure PHP solution.
I currently send requests to couch like this
...ANSWER
Answered 2018-May-04 at 20:42It's a litte bit ago since i have researched in this topic, but simply what you are looking for is a queue runner system. At my old employee i have worked with a custom built queue runner in php.
That mean, you have e.g. 4 queue runners. Thats are php processes which are watching a control table maybe "queue". Each time a queue process is inserted in maybe status "new" a runner lock this entry and start the process with a fork job.
PHP forking: http://php.net/manual/de/function.pcntl-fork.php
so... this 4 queue runners can maybe let's say fork 10 processes, than you have 40 parallel working processes.
To seperate them what each do is in best way another control tables from which each job selects a amount of data with LIMIT and OFFSET Queries. Lets say job 1 selects the first 0-20 rows, job 2 the 21-40 rows.
Edit:
After a little research this looks nearly similar to on what i've worked: https://github.com/CoderKungfu/php-queue
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install couchdb-php
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