1.0.0 • Published 9 years ago

redis-linq v1.0.0

Weekly downloads
9
License
ISC
Repository
-
Last release
9 years ago
					Inventt Linq

This package provides simplified access to redis

METHODS

Save

  • Creates a Key in Redis
  • Parameters : Key - Name to retrieve/change information Object - Data to be retrieved Expiration - In seconds, sets an expiration date for that key Callback - Function to be called when it is done

  • Responses Err Reply

Get

  • Retrieves a specific key from the database
  • Parameters : Key Callback

  • Responses Err Reply - Null if key doesn`t exists

Exists

  • Checks if a Key exists
  • Parameters : Key Callback

  • Responses Err Reply - (0 or 1 )

Delete

  • Removes the Key from the database
  • Parameters : * Key

Refresh

  • If a Key is set to expire, this refreshes it to the new expiration date (if it's undefined, it persists the key)
  • Parameters : Key Expiration

Update

  • Changes the object saved under the desired Key
  • Parameters : Key Object Expiration Callback

  • Responses Err Reply

Length

  • Retrieves the length of all keys in the database
  • Parameters : * Callback

  • Responses Err Reply


USAGE EXAMPLE :

var db = require('redis-linq');

//saves the key 'example1'

db.Save('example1',{obj:'test'},10,function(err,reply){

if(err)
	console.log('Error occured connecting to redis');

console.log('Result',reply);

//Note that this key will expire after 10 seconds

});

db.Get('example1',function(err,reply){

if(err)
	console.log('Error occured connecting to redis');

if(reply === null)	
	console.log('Key does not exist');


console.log('Result: ',reply);

//this will log:
 Result: {obj:'test'}

})

db.Exists('example1',function(err,reply){

if(err)
	console.log('Error occured connecting to redis');


if(reply == 0)
	console.log('Key expired');
else
	console.log('Key still alive');

});

//deletes key

db.Delete('example1');

// persists key

db.Refresh('example1');

// Refreshes key for another 10 seconds

db.Refresh('example1',10);

//changes the data and expiration time of 'example1'

db.Update('example1',{obj:'test changed'},1000,function(err,reply){

if(err)
	console.log('Error occured connecting to redis');

console.log('Result',reply);

//Note that this key will expire after 1000 seconds

});

db.Length(function(err,reply){

if(err)
	console.log('Error occured connecting to redis');

console.log('Result',reply);
// This will log how many keys are stored in the db

})

1.0.0

9 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago