{"id":17928632,"url":"https://github.com/evilsocket/phpgibson","last_synced_at":"2025-09-17T23:31:50.662Z","repository":{"id":8959974,"uuid":"10699249","full_name":"evilsocket/phpgibson","owner":"evilsocket","description":"The phpgibson extension provides an API for communicating with the Gibson cache server.","archived":false,"fork":false,"pushed_at":"2013-07-30T10:07:47.000Z","size":546,"stargazers_count":9,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-30T20:51:39.181Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://gibson-db.in/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evilsocket.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-14T22:52:54.000Z","updated_at":"2024-08-12T19:22:32.000Z","dependencies_parsed_at":"2022-09-14T10:11:46.333Z","dependency_job_id":null,"html_url":"https://github.com/evilsocket/phpgibson","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evilsocket%2Fphpgibson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evilsocket%2Fphpgibson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evilsocket%2Fphpgibson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evilsocket%2Fphpgibson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evilsocket","download_url":"https://codeload.github.com/evilsocket/phpgibson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233430283,"owners_count":18675063,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-28T21:04:24.326Z","updated_at":"2025-09-17T23:31:49.749Z","avatar_url":"https://github.com/evilsocket.png","language":"Shell","readme":"# PhpGibson\n\nThe phpgibson extension provides an API for communicating with the [Gibson](http://gibson-db.in/) cache server. It is released under the BSD License.\nThis code has been developed and maintained by Simone Margaritelli.\n\nYou can send comments, patches, questions [here on github](https://github.com/evilsocket/phpgibson/issues) or to evilsocket@gmail.com ([@evilsocket](http://twitter.com/evilsocket)).\n\n\n# Table of contents\n-----\n1. [Installing/Configuring](#installingconfiguring)\n   * [Installation](#installation)\n   * [Installation on OSX](#installation-on-osx)\n   * [Building on Windows](#building-on-windows)\n1. [Classes and methods](#classes-and-methods)\n   * [Usage](#usage)\n   * [Connection](#connection)\n   * [Methods](#methods)\n\n-----\n\n# Installing/Configuring\n-----\n\nEverything you should need to install PhpGibson on your system.\n\n## Installation\n\n~~~\nphpize\n./configure\nmake \u0026\u0026 make install\n~~~\n\nThis extension exports a single class, [Gibson](#class-gibson).\n\n\n## Installation on OSX\n\nIf the install fails on OSX, type the following commands in your shell before trying again:\n~~~\nMACOSX_DEPLOYMENT_TARGET=10.6\nCFLAGS=\"-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp\"\nCCFLAGS=\"-arch i386 -arch x86_64 -g -Os -pipe\"\nCXXFLAGS=\"-arch i386 -arch x86_64 -g -Os -pipe\"\nLDFLAGS=\"-arch i386 -arch x86_64 -bind_at_load\"\nexport CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET\n~~~\n\nIf that still fails and you are running Zend Server CE, try this right before \"make\": `./configure CFLAGS=\"-arch i386\"`.\n\n## Building on Windows\n\n1. Install visual studio 2008 (express or professional). If using visual studio 2008 express, also install the latest windows SDK.\n2. Download PHP source code\n3. Extract to C:\\php\\php-5.4.9\n4. Download http://windows.php.net/downloads/php-sdk/php-sdk-binary-tools-20110915.zip and extract to C:\\php\n5. In cmd.exe\n  * cd C:\\php\\php-5.4.9\\ext\n  * git clone https://github.com/evilsocket/phpgibson.git\n  * cd ..\n  * buildconf.js\n  * \"C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Bin\\SetEnv\" /x86 /xp /release\n  * path \"C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\Bin\";%PATH%\n  * bin\\phpsdk_setvars.bat\n  * \"C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\vcvarsall.bat\"\n  * configure.js --disable-all --enable-cli --enable-gibson \n  * nmake php_gibson.dll\n  * fix any compilation errors\n\n# Classes and methods\n-----\n\n## Usage\n\n1. [Class Gibson](#class-gibson)\n\n### Class Gibson\n-----\n_**Description**_: Creates a Gibson client\n\n##### *Example*\n\n~~~\n$gb = new Gibson();\n~~~\n\n## Connection\n\n1. [connect](#connect) - Connect to a server\n1. [pconnect](#pconnect) - Create a persistent connection or reuse a previous one if present.\n1. [quit](#quit) - Close the connection\n\n### connect\n-----\n_**Description**_: Connects to a Gibson instance.\n\n##### *Parameters*\n\n*host*: string. can be a host, or the path to a unix domain socket  \n*port*: int, optional  \n*timeout*: float, value in milli seconds (optional, default is 0 meaning unlimited)  \n\n##### *Return value*\n\n*BOOL*: `TRUE` on success, `FALSE` on error.\n\n##### *Example*\n\n~~~\n$gibson-\u003econnect('127.0.0.1', 10128);\n$gibson-\u003econnect('127.0.0.1'); // port 10128 by default\n$gibson-\u003econnect('127.0.0.1', 10128, 200); // 200 ms timeout.\n$gibson-\u003econnect('/tmp/gibson.sock'); // unix domain socket.\n~~~\n\n### pconnect\n-----\n_**Description**_: Create a persistent connection or reuse a previous one if present. If a previous connection exists but\nis not valid ( timed out, disconnected, etc ) the connection will be enstablished again.\n\n##### *Parameters*\n\n*host*: string. can be a host, or the path to a unix domain socket  \n*port*: int, optional  \n*timeout*: float, value in milli seconds (optional, default is 0 meaning unlimited)  \n\n##### *Return value*\n\n*BOOL*: `TRUE` on success, `FALSE` on error.\n\n##### *Example*\n\n~~~\n$gibson-\u003epconnect('127.0.0.1', 10128);\n$gibson-\u003epconnect('127.0.0.1'); // port 10128 by default\n$gibson-\u003epconnect('127.0.0.1', 10128, 200); // 200 ms timeout.\n$gibson-\u003epconnect('/tmp/gibson.sock'); // unix domain socket.\n~~~\n\n### quit\n-----\n_**Description**_: Disconnects from the Gibson instance.\n\n## Methods\n\n1. [getLastError](#getLastError) - If an error occurred, return its human readable description.\n1. [set](#set) - Set the value for the given key, with an optional TTL.\n1. [mset](#mset) - Set the value for keys verifying the given expression.\n1. [ttl](#ttl) - Set the TTL of a key.\n1. [mttl](#mttl) - Set the TTL for keys verifying the given expression.\n1. [get](#get) - Get the value for a given key.\n1. [mget](#mget) - Get the values for keys verifying the given expression.\n1. [del](#del) - Delete the given key.\n1. [mdel](#mdel) - Delete keys verifying the given expression.\n1. [inc](#inc) - Increment by one the given key.\n1. [minc](#minc) - Increment by one keys verifying the given expression.\n1. [mdec](#mdec) - Decrement by one the given keys.\n1. [dec](#dec) - Decrement by one keys verifying the given expression.\n1. [lock](#lock) - Prevent the given key from being modified for a given amount of seconds.\n1. [mlock](#mlock) - Prevent keys verifying the given expression from being modified for a given amount of seconds.\n1. [unlock](#unlock) - Remove the lock on a given key.\n1. [munlock](#munlock) - Remove the lock on keys verifying the given expression.\n1. [count](#count) - Count items for a given expression.\n1. [meta](#meta) - Obtain a specific information about a given item.\n1. [stats](#stats) - Get system stats about the Gibson instance.\n1. [keys](#keys) - Return a list of keys matching the given prefix.\n1. [ping](#ping) - Ping the server instance to refresh client last seen timestamp.\n\n### getLastError\n-----\n_**Description**_: If an error occurred, return its human readable description.\n\n##### *Parameters*\nNone.\n\n##### *Return value*\n*string*: The error description.\n\n##### *Example*\n~~~\necho $gibson-\u003egetLastError();\n~~~\n\n### set\n-----\n_**Description**_: Set the value for the given key, with an optional TTL.\n\n##### *Parameters*\n*key* (string) The key to set.\n*value* (string) The value.\n*ttl* (int) The optional ttl in seconds.\n\n##### *Return value*\n*Mixed* The string value itself in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003eset( 'foo', 'bar' );\n$gibson-\u003eset( 'foo2', 'bar2', 2 ); // 2 seconds TTL\n~~~\n\n### mset\n-----\n_**Description**_: Set the value for keys verifying the given expression.\n\n##### *Parameters*\n*key* (string) The key prefix to use as expression.\n*value* (string) The value.\n\n##### *Return value*\n*Mixed* The integer number of updated items in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003eset( 'foo', 'bar' );\n$gibson-\u003eset( 'fuu', 'rar' );\n\n$gibson-\u003emset( 'f', 'yeah' );\n~~~\n\n### ttl\n-----\n_**Description**_: Set the TTL of a key.\n\n##### *Parameters*\n*key* (string) The key.\n*ttl* (integer) The TTL in seconds.\n\n##### *Return value*\n*BOOL* `TRUE` in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003ettl( 'foo', 3600 ); // 1 hour TTL\n~~~\n\n### mttl\n-----\n_**Description**_: Set the TTL for keys verifying the given expression.\n\n##### *Parameters*\n*key* (string) The key prefix to use as expression.\n*ttl* (integer) The TTL in seconds.\n\n##### *Return value*\n*Mixed* The integer number of updated items in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003emttl( 'f', 3600 ); // 1 hour TTL for every f* key.\n~~~\n\n### get\n-----\n_**Description**_: Get the value for a given key.\n\n##### *Parameters*\n*key* (string) The key to get.\n\n##### *Return value*\n*Mixed* An integer or string value (depends on item encoding) in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003eset( 'foo', 'bar' );\n$gibson-\u003eget( 'foo' ); \n~~~\n\n### mget\n-----\n_**Description**_: Get the value for a given key.\n\n##### *Parameters*\n*key* (string) The key prefix to use as expression.\n\n##### *Return value*\n*Mixed* An array of key =\u003e value items in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003emget( 'f' ); \n~~~\n\n### del\n-----\n_**Description**_: Delete the given key.\n\n##### *Parameters*\n*key* (string) The key to delete.\n\n##### *Return value*\n*BOOL* `TRUE` in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003eset( 'foo', 'bar' );\n$gibson-\u003edel( 'foo' ); \n~~~\n\n### mdel\n-----\n_**Description**_: Delete keys verifying the given expression.\n\n##### *Parameters*\n*key* (string) The key prefix to use as expression.\n\n##### *Return value*\n*Mixed* The integer number of deleted items in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003emdel( 'f' ); // Delete every f* key.\n~~~\n\n### inc\n-----\n_**Description**_: Increment by one the given key.\n\n##### *Parameters*\n*key* (string) The key to increment.\n\n##### *Return value*\n*Mixed* The incremented integer value in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003eset( 'foo', '1' );\n$gibson-\u003einc( 'foo' ); \n~~~\n\n### minc\n-----\n_**Description**_: Increment by one keys verifying the given expression.\n\n##### *Parameters*\n*key* (string) The key prefix to use as expression.\n\n##### *Return value*\n*Mixed* The integer number of incremented items in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003eminc( 'f' ); // Increment by one every f* key.\n~~~\n\n### dec\n-----\n_**Description**_: Decrement by one the given key.\n\n##### *Parameters*\n*key* (string) The key to decrement.\n\n##### *Return value*\n*Mixed* The decremented integer value in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003eset( 'foo', '1' );\n$gibson-\u003edec( 'foo' ); \n~~~\n\n### mdec\n-----\n_**Description**_: Decrement by one keys verifying the given expression.\n\n##### *Parameters*\n*key* (string) The key prefix to use as expression.\n\n##### *Return value*\n*Mixed* The integer number of decremented items in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003emdec( 'f' ); // Decrement by one every f* key.\n~~~\n\n### lock\n-----\n_**Description**_: Prevent the given key from being modified for a given amount of seconds.\n\n##### *Parameters*\n*key* (string) The key.\n*time* (integer) The time in seconds to lock the item.\n\n##### *Return value*\n*BOOL* `TRUE` in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003elock( 'foo', 3600 ); // 1 hour lock\n~~~\n\n### mlock\n-----\n_**Description**_: Prevent keys verifying the given expression from being modified for a given amount of seconds.\n\n##### *Parameters*\n*key* (string) The key prefix to use as expression.\n*ttl* (integer) The lock period in seconds.\n\n##### *Return value*\n*Mixed* The integer number of locked items in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003emlock( 'f', 3600 ); // 1 hour lock for every f* key.\n~~~\n\n### unlock\n-----\n_**Description**_: Remove the lock from the given key.\n\n##### *Parameters*\n*key* (string) The key.\n\n##### *Return value*\n*BOOL* `TRUE` in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003eunlock( 'foo' ); // foo now is unlocked\n~~~\n\n### munlock\n-----\n_**Description**_: Remove the lock on keys verifying the given expression.\n\n##### *Parameters*\n*key* (string) The key prefix to use as expression.\n\n##### *Return value*\n*Mixed* The integer number of unlocked items in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003emunlock( 'f' ); // Every f* key is now unlocked.\n~~~\n\n### count\n-----\n_**Description**_: Count items for a given expression.\n\n##### *Parameters*\n*key* (string) The key prefix to use as expression.\n\n##### *Return value*\n*Mixed* The integer count of items in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003ecount( 'f' ); // Count every f* key\n~~~\n\n### meta \n-----\n_**Description**_: Obtain a specific information about a given item.\n\n##### *Parameters*\n*key* (string) The key of the value to search.\n*field* (string) The information name to retrieve, allowed values follow.\n\n- *size* The size in bytes of the item value.\n- *encoding* The value encoding.\n- *access* Timestamp of the last time the item was accessed.\n- *created* Timestamp of item creation.\n- *ttl* Item specified time to live, -1 for infinite ttl.\n- *left* Number of seconds left for the item to live if a ttl was specified, otherwise -1.\n- *lock* Number of seconds the item is locked, -1 if there's no lock.\n\n##### *Return value*\n*Mixed* An integer with the value in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003eset( 'foo', 'bar' );\n\necho $gibson-\u003emeta( 'foo', 'created' ).\"\\n\"; // will print the actual timestamp\n~~~\n\n### stats\n-----\n_**Description**_: Get system stats about the Gibson instance.\n\n##### *Parameters*\nNone\n\n##### *Return value*\n*Mixed* An array of key =\u003e value items in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\nprint_r( $gibson-\u003estats() );\n~~~\n\nOutput:\n~~~\nArray\n(\n    [server_started] =\u003e 1369857026\n    [server_time] =\u003e 1369857149\n    [first_item_seen] =\u003e 1369857132\n    [last_item_seen] =\u003e 1369857132\n    [total_items] =\u003e 1\n    [total_compressed_items] =\u003e 0\n    [total_clients] =\u003e 1\n    [total_cron_done] =\u003e 1228\n    [memory_used] =\u003e 1772\n    [memory_peak] =\u003e 1772\n    [item_size_avg] =\u003e 1772\n)\n~~~\n\n### keys \n-----\n_**Description**_: Return a list of keys matching the given prefix.\n\n##### *Parameters*\n*prefix* (string) The key prefix to use as expression.\n\n##### *Return value*\n*Mixed* The list of matching keys, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003eset( 'app:count:a', 1 );\n$gibson-\u003eset( 'app:count:b', 2 );\n\n$gibson-\u003ekeys( 'app:count:' ); // Will return an array with both keys.\n~~~\n\n### ping\n-----\n_**Description**_: Ping the server instance to refresh client last seen timestamp.\n\n##### *Parameters*\nNone\n\n##### *Return value*\n*BOOL* `TRUE` in case of success, `FALSE` in case of failure.\n\n##### *Example*\n~~~\n$gibson-\u003eping(); \n~~~\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevilsocket%2Fphpgibson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevilsocket%2Fphpgibson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevilsocket%2Fphpgibson/lists"}