Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

memcached-mock

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memcached-mock - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

146

index.js

@@ -116,3 +116,10 @@ /*

function Memcached(locations, options) {
extend(this, Memcached.config, options);
events.EventEmitter.call(this);
if (locations)
this.servers = [].concat(locations);
else
this.servers = [];
}

@@ -332,2 +339,16 @@

/**
* Provide callback an array of server version information
*/
version: function(callback) {
invoke(callback, {self: this,
type: 'version',
args: arguments,
names: ['callback']},
undefined,
this.servers.map(function(s) {
return {server: s, version: "1.4.20", major: "1", minor: "4", bugfix: "20"};
}));
},
/**
* Flush the contents of the cache

@@ -343,2 +364,107 @@ */

undefined, [true]);
},
/**
* Provide callback an array of server stats
*/
stats: function(callback) {
var info = {
"pid":1,"uptime":1,"time":Math.round(Date.now()/1000),"version":"1.4.20","libevent":"2.0.22-stable","pointer_size":64,"rusage_user":"0.0","rusage_system":"0.0","curr_connections":1,"total_connections":1,"connection_structures":1,"reserved_fds":0,"cmd_get":0,"cmd_set":0,"cmd_flush":0,"cmd_touch":0,"get_hits":0,"get_misses":0,"delete_misses":0,"delete_hits":0,"incr_misses":0,"incr_hits":0,"decr_misses":0,"decr_hits":0,"cas_misses":0,"cas_hits":0,"cas_badval":0,"touch_hits":0,"touch_misses":0,"auth_cmds":0,"auth_errors":0,"bytes_read":1,"bytes_written":1,"limit_maxbytes":67108864,"accepting_conns":1,"listen_disabled_num":0,"threads":4,"conn_yields":0,"hash_power_level":16,"hash_bytes":524288,"hash_is_expanding":0,"malloc_fails":0,"bytes":0,"curr_items":0,"total_items":0,"expired_unfetched":0,"evicted_unfetched":0,"evictions":0,"reclaimed":0,"crawler_reclaimed":0
};
invoke(callback, {self: this,
type: 'stats',
args: arguments,
names: ['callback']},
undefined,
this.servers.map(function(s) {
return extend({server: s}, info);
}));
},
/**
* Provide callback an array of server settings
*/
settings: function(callback) {
var info = {
"maxbytes":67108864,"maxconns":1024,"tcpport":11211,"udpport":11211,"inter":"NULL","verbosity":0,"oldest":13516,"evictions":"on","domain_socket":"NULL","umask":700,"growth_factor":"1.25","chunk_size":48,"num_threads":4,"num_threads_per_udp":4,"stat_key_prefix":":","detail_enabled":"no","reqs_per_event":20,"cas_enabled":"yes","tcp_backlog":1024,"binding_protocol":"auto-negotiate","auth_enabled_sasl":"no","item_size_max":1048576,"maxconns_fast":"no","hashpower_init":0,"slab_reassign":"no","slab_automove":0,"lru_crawler":"no","lru_crawler_sleep":100,"lru_crawler_tocrawl":0,"tail_repair_time":0,"flush_enabled":"yes","hash_algorithm":"jenkins"
};
invoke(callback, {self: this,
type: 'settings',
args: arguments,
names: ['callback']},
undefined,
this.servers.map(function(s) {
return extend({server: s}, info);
}));
},
/**
* Provide callback an array of server slab information
*/
slabs: function(callback) {
var info = {
"1":{"chunk_size":96,"chunks_per_page":10922,"total_pages":1,"total_chunks":10922,"used_chunks":0,"free_chunks":10922,"free_chunks_end":0,"mem_requested":0,"get_hits":0,"cmd_set":0,"delete_hits":0,"incr_hits":0,"decr_hits":0,"cas_hits":0,"cas_badval":0,"touch_hits":0},"active_slabs":{"undefined":1},"total_malloced":{"undefined":1048512}
};
invoke(callback, {self: this,
type: 'slabs',
args: arguments,
names: ['callback']},
undefined,
this.servers.map(function(s) {
return extend({server: s}, info);
}));
},
/**
* Provide callback an array of server items information
*/
items: function(callback) {
var len = Object.keys(cache).length;
var info = len === 0 ? {} :
{"1":{"number":len,"age":1,"evicted":0,"evicted_nonzero":0,"evicted_time":0,"outofmemory":0,"tailrepairs":0,"reclaimed":0,"expired_unfetched":0,"evicted_unfetched":0,"crawler_reclaimed":0}}
;
invoke(callback, {self: this,
type: 'info',
args: arguments,
names: ['callback']},
undefined,
this.servers.map(function(s) {
return extend(len > 0 ? {server: s} : {}, info);
}));
},
/**
* Provide callback with a set of cachedump information
*/
cachedump: function(server, slabid, limit, callback) {
var items = Object.keys(cache).map(function(key) {
return {key: key,
b: String(cache[key].value).length,
s: Math.round(cache[key].expires/1000)};
});
function result() {
switch(items.length) {
case 0: return;
case 1: return items[0];
default: return items;
};
}
invoke(callback, {self: this,
type: 'cachedump',
args: arguments,
names: ['server', 'slabid', 'number', 'callback']},
undefined, result());
},
/**
* End the memcached connection
*/
end: function() {
}

@@ -348,2 +474,22 @@

/**
* Config options
*/
Memcached.config = {
maxKeySize: 250,
maxExpiration: 2592000,
maxValue: 1048576,
poolSize: 10,
algorithm: 'md5',
reconnect: 18000000,
timeout: 5000,
retries: 5,
failures: 5,
retry: 30000,
remove: false,
keyCompression: true,
idle: 5000
};
module.exports = Memcached;

2

package.json
{
"name": "memcached-mock",
"version": "0.0.2",
"version": "0.0.3",
"description": "A mock implementation of memcached to use as a replacement in tests",

@@ -5,0 +5,0 @@ "keywords": [

@@ -9,5 +9,7 @@ # memcached-mock

* append(key, value, callback)
* cachedump(server, slabid, limit, callback)
* cas(key, value, cas, ttl, callback)
* decr(key, amount, callback)
* del(key, callback)
* end()
* flush(callback)

@@ -18,5 +20,10 @@ * get(key, callback)

* incr(key, amount, callback)
* items(callback)
* prepend(key, value, callback)
* replace(key, value, ttl, callback)
* set(key, value, ttl, callback)
* settings(callback)
* slabs(callback)
* stats(callback)
* version(callback)

@@ -23,0 +30,0 @@ Example usage:

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc