# gibson-client

> Gibson client

Latest version **1.0.5** (published 2013-08-04) · 0 weekly downloads

## Install

```sh
npm install gibson-client
pnpm add gibson-client
yarn add gibson-client
bun add gibson-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2013-08-04 |
| First published | 2013-07-21 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.6.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Simone Margaritelli |
| Maintainers | evilsocket |
| Keywords | gibson, cache, server, client, gibson cache server, cache server |

## Links

- npm: https://www.npmjs.com/package/gibson-client
- Repository: https://github.com/evilsocket/node-gibson
- Issues: https://github.com/evilsocket/node-gibson/issues
- npm.io page: https://npm.io/package/gibson-client

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2013-08-04
- 1.0.4 — 2013-07-31
- 1.0.3 — 2013-07-23
- 1.0.2 — 2013-07-21

## README

node.js Gibson client
========================

A pure-JavaScript Gibson client library for node.

<http://gibson-db.in/>

Connection
----------

Create a Client object to start working.
Host and port can be passed to the constructor with a connection string, both for tcp and unix sockets.

	var gibson = require('./gibson');

	var unix_client = new gibson.Client('unix:///var/run/gibson.sock');
    var tcp_client = new gibson.Client('tcp://127.0.0.1:10128');

The Client object constructor has three more optional parameters, a connection timeout ( default to infinite ), a boolean flag
which specifies if the tcp no delay flag should be used on the socket ( default to true ), and a string with a custom encoding
to be used while decoding data ( default to utf8 ), so the following line:

    var client = new gibson.Client( 'tcp://127.0.0.1:10128', 100, true, 'ascii' );

Will create a client instance bound to a tcp socket, with a 100ms timeout, the tcp no delay flag set and that will use plain 
ascii encoding on incoming data.

Events
------

The Client object emits 4 important events - connect, close, timeout and error.

	client.on('connect', function(){
		// no arguments - we've connected
	});

	client.on('close', function(){
		// no arguments - connection has been closed
	});

	client.on('timeout', function(){
		// no arguments - socket timed out
	});

	client.on('error', function(e){
		// there was an error - exception is 1st argument
	});
	
	// connect to the Gibson server after subscribing to some or all of these events
	client.connect();

Methods
-------

After connecting, you can start to make requests.

	client.get('key', function(error, result){

		// all of the callbacks have two arguments, the first one will be
        // null if no error occurred, the second one will contain the decoded
        // data ( if any ) received from the server.

	});

	client.set( 3600, 'key', 'value', function(error, result){

		// create ( or replace ) a value with a TTL of 3600 seconds.
        // set the TTL to zero and the value will never expire.

	});

	client.del('key', function(error, result){

		// delete a key from cache.
	});

	client.stats(function(error, result)){

		// grab the server statistics
	});

Every available command is automatically mapped to a client method, so follow the 
[official reference](http://gibson-db.in/commands.php) of Gibson commands.

Once you're done, close the connection.

	client.close();

License
---

Released under the BSD license.  
Copyright &copy; 2013, Simone Margaritelli <evilsocket@gmail.com>  
All rights reserved.

---
_Source: https://npm.io/package/gibson-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
