Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit 5544f15bad627bd3e69f693c27691303d7884cd3 @lcastelli committed Jun 3, 2010
Showing with 882 additions and 0 deletions.
  1. +13 −0 INSTALL
  2. +29 −0 LICENSE
  3. +38 −0 README
  4. +351 −0 chdb.c
  5. +60 −0 chdb.h
  6. +43 −0 config.m4
  7. +316 −0 php_chdb.c
  8. +32 −0 php_chdb.h
13 INSTALL
@@ -0,0 +1,13 @@
+To build and install chdb you need cmph 0.9 (http://cmph.sourceforge.net/). Once
+cmph is installed, you can build chdb by running:
+ phpize --with-chdb
+ ./configure
+ make
+
+And finally you can install it by:
+ make install
+
+The configuration script tries to detect the location of cmph automatically.
+Should that fail, you can manually specify the prefix directory in which it's
+installed by running:
+ phpize --with-chdb --with-libcmph-dir=DIR
29 LICENSE
@@ -0,0 +1,29 @@
+Copyright (C) 2010, Hyves (Startphone Ltd.) All rights reserved.
+
+Lorenzo Castelli <lorenzo@hyves.nl>
+Henk Punt <henk@hyves.nl>
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of Hyves (Startphone Ltd.) nor the names of its
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 README
@@ -0,0 +1,38 @@
+chdb implements a read-only memory mapped hash-table for PHP.
+
+In PHP the only way to define large amounts of constants - for instance to store
+the association between language and text keys and the corresponding translation
+- is to use lots of defines, class consts, or create some humongous array
+structure.
+
+Even with an op-code cacher like APC or e-accelerator, defining constants this
+way is both CPU and memory consuming, as each instance of php will need to
+load/parse/execute the opcodes to define the constants for each request.
+
+chdb is a solution for this problem because:
+ - It takes virtually no time to load initially.
+ - Only the pages of the file which are actually used are read from the disk.
+ - Once a page is loaded it is shared across all the processes in the same
+ machine and cached across multiple requests.
+
+All these functionalities are provided by the operative system itself as
+features of memory mapped files. chdb thus provides to PHP something similar to
+what the data section provides to lower level programming languages like C.
+
+If you are using PHP in a typical setup for a big website which remains stable
+between releases you might benefit from the chdb extension. In that case you
+would create a disk file containing a hashmap of key-value pairs at deploy-time,
+and then map it into the memory of each php process at run-time.
+
+An example of use of chdb for this would be to run the following at deploy-time:
+ $data = array(
+ 'key1' => 'value1',
+ 'key2' => 'value2',
+ // ...
+ );
+ chdb_create('data.chdb', $data);
+
+Then at run-time, the keys stored in the file can be read by:
+ $chdb = new chdb('data.chdb');
+ $value1 = $chdb->get('key1');
+ $value2 = $chdb->get('key2');
Oops, something went wrong.

0 comments on commit 5544f15

Please sign in to comment.