npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

memcachedjs

v0.0.1

Published

Port of Memcached server for Node.js

Downloads

9

Readme

______  ___                                        ______        _________  _________________
___   |/  /_____ _______ ___ _____________ ___________  /_ _____ ______  /  ______  /__  ___/
__  /|_/ / _  _ \__  __ `__ \_  ___/_  __ `/_  ___/__  __ \_  _ \_  __  /   ___ _  / _____ \
_  /  / /  /  __/_  / / / / // /__  / /_/ / / /__  _  / / //  __// /_/ /___ / /_/ /  ____/ /
/_/  /_/   \___/ /_/ /_/ /_/ \___/  \__,_/  \___/  /_/ /_/ \___/ \__,_/ _(_)\____/   /____/

Memcached.js

Memcached.js is a port of Memcached to Javascript, running on Node.Js.

Install

  $ git clone git://github.com/dalssoft/memcached.js.git
  $ cd memcached.js
  $ ./bin/memcachedjs

What does it do?

From the original project:

"Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering."

This version:

  • Non blocking operations: "take near constant time to execute, no matter how much data is in the cache."
    • Well, not completely true: adding and removing items to cache allocate memory dynamically, because it doesn't allocate memory upfront when the server starts. So, it may take sometime allocating memory. We will fix it in the future, but for now, it probably won't hurt you.
    • On the other hand, the cache operates on algorithms with O(1) complexity. No complex timers / triggers. Just a hash and linked list.
    • And of course, it uses the non-blocking event machine provided by Node.js
  • Supported commands on this version: get, set, flush_all, delete, add, replace, stats
  • ASCII and Binary memcached protocol

What it doesn't do (yet)?

  • It is not a client for memcached
  • UDP protocol
  • cas, gets, append, prepend, version, quit, incr and decr commands
  • delete queue
  • stats command with params
  • Pre-allocate memory or pagination
  • Sophisticated cache strategies. All it does right now is the the old and good LRU, for all items. No discrimination.
    • However, now it uses the same heuristic that the original project uses to clean expired items when it needs more space.

Project goals (sanity is not a prerequisite)

  1. Reach the same performance as C implementation
  2. Implement the same set of features the original project have
  3. Be a hackable memcached implementation

When Memory Is Reclaimed

Memory for an item is not actively reclaimed. If you store an item and it expires, it sits in the LRU cache at its position until it falls to the end and is reused.

However, if you fetch an expired item, memcached.js will find the item, notice that it's expired, and free its memory. This gives you the common case of normal cache churn reusing its own memory.

Items can also be evicted to make way for new items that need to be stored. But before that, we will try to drop a few expired items at the end of the list.

Current State

Currently, the project is Alpha (version 0.0.4), not tested in production enviroment. However, it was tested using diferent scenarios and condition, with different clients (see /test/from_clients folder and the list below).

I haven't done any serious performance test, just simple ones. Compared with the original memcached written in C, memcached.js performance is between 30% and 50% slower. The situation may worsen as new functionality is added (currently, it's ~ 1000 of javascript LOC against ~ 7500 of C LOC, according to CLOC). At the same time, it can be improved since no optimization has been done yet and I can see many places where it could do better.

Tested on Node.js since version v0.3.6-pre. Last check: Node.js v0.10.5

Clients tested:

C/C++:

Ruby:

Node.js:

Perl:

Using Memcached.js

  $ cd memcached.js
  $ ./bin/memcachedjs --log 1

On the client side:

  $ telnet localhost 11211
  stats

Test:

  $ rspec -fd -c test/from_clients/ruby_spec_test.rb

Implemented commands

          ASCII    Bin
Get         X       X
Set         X       X
Add         X       X
Replace     X       X
Delete      X       X
Increment
Decrement
Quit
Flush       X       X
GetQ
No-op               X
Version             X
GetK
GetKQ               X
Append
Prepend
Stat        X
SetQ
AddQ
ReplaceQ
DeleteQ
IncrementQ
DecrementQ
QuitQ
FlushQ
AppendQ
PrependQ