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

iomem

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iomem

Memcached client with binary protocol support and multi keys commands

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1K
decreased by-1.95%
Maintainers
1
Weekly downloads
 
Created
Source

iomem

WARNING! THIS SOFTWARE IS A WORK IN PROGRESS! DO NOT USE IT!

Memcached client implementing binary protocol with native multiple keys support.

Features

  • Binary Memcached protocol implementation
  • Multiple keys support aka multi-get, multi-set, multi-del, etc..
  • Async interface
  • Streams interface
  • Hashring aka consistent hashing

Installation

yarn add iomem

or

npm install iomem

Usage

Default

const Memcached = require('iomem')
const iomem = new Memcached()

await iomem.set('test:key', 'hello')
console.log(await iomem.get('test:key'))

Multi-get, multi-set, multi-del, etc..

const Memcached = require('iomem')
const iomem = new Memcached()

await iomem.set(['test:key1', 'test:key2'], ['hello', 'world'])
console.log(await iomem.get(['test:key1', 'test:key2']))
await iomem.del(['test:key1', 'test:key2'])

Custom servers

const Memcached = require('iomem')
const iomem = new Memcached(['127.0.0.1:11211', '127.0.0.2:11211'])
...

Address formats:

// host:port
or
// username:password@host:port
or
// /path/to/memcached.sock

Streams

const Memcached = require('iomem')
const iomem = new Memcached(['127.0.0.1:11211'], { stream: true })

const { pipeline, Writable } = require('node:stream')

class Echo extends Writable {
  _write (data, _, cb) {
    console.log(data)
    cb()
  }
}

pipeline(iomem.get('test:a'), new Echo({ objectMode: true }), err => {
  if (err) {
    console.log(err)
  }
})

Options

{
  stream: false, // set true to use streams instead of promises
  expiry: 60 * 60 * 24 * 1, // 1 day, time interval in seconds
  maxConnection: 10, // max connections per server
  connectionTimeout: 1000, // connection timeout
  timeout: 500, // request timeout
  retries: 2 // request retries
}

Keywords

FAQs

Package last updated on 20 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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