All Projects → arthurnn → Memcached

arthurnn / Memcached

Licence: afl-3.0
A Ruby interface to the libmemcached C client

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to Memcached

ddos
Simple dos attack utility
Stars: ✭ 36 (-91.53%)
Mutual labels:  memcached
Zhong
Reliable, distributed cron.
Stars: ✭ 281 (-33.88%)
Mutual labels:  memcached
Roma
ROMA: A Distributed Key-Value Store in Ruby
Stars: ✭ 318 (-25.18%)
Mutual labels:  memcached
b52
b52 is a fast experimental Key/value database. With support for the memcache protocol.
Stars: ✭ 20 (-95.29%)
Mutual labels:  memcached
Arcus
ARCUS is the NAVER memcached with lists, sets, maps and b+trees. http://naver.github.io/arcus
Stars: ✭ 273 (-35.76%)
Mutual labels:  memcached
Neard
🎲 Portable WAMP software stack
Stars: ✭ 296 (-30.35%)
Mutual labels:  memcached
memcached
Memcached Operator for Kubernetes
Stars: ✭ 18 (-95.76%)
Mutual labels:  memcached
React Component Caching
Speedier server-side rendering with component caching in React 16
Stars: ✭ 365 (-14.12%)
Mutual labels:  memcached
Scrapbook
PHP cache library, with adapters for e.g. Memcached, Redis, Couchbase, APC(u), SQL and additional capabilities (e.g. transactions, stampede protection) built on top.
Stars: ✭ 279 (-34.35%)
Mutual labels:  memcached
Gokv
Simple key-value store abstraction and implementations for Go (Redis, Consul, etcd, bbolt, BadgerDB, LevelDB, Memcached, DynamoDB, S3, PostgreSQL, MongoDB, CockroachDB and many more)
Stars: ✭ 314 (-26.12%)
Mutual labels:  memcached
anchor
High-Performance Erlang Memcached Client
Stars: ✭ 15 (-96.47%)
Mutual labels:  memcached
Bashcached
memcached server built on bash + socat
Stars: ✭ 270 (-36.47%)
Mutual labels:  memcached
Quack
Quack Toolkit is a set of tools to provide denial of service attacks. Quack Toolkit includes SMS attack tool, HTTP attack tool and many other attack tools.
Stars: ✭ 305 (-28.24%)
Mutual labels:  memcached
cache-trace
A collection of Twitter's anonymized production cache traces.
Stars: ✭ 89 (-79.06%)
Mutual labels:  memcached
Dotnetguide
🦸【C#/.NET/.NET Core学习、工作、面试指南】概述:C#/.NET/.NET Core基础知识,学习资料、文章、书籍,社区组织,工具和常见的面试题总结。以及面试时需要注意的事项和优秀简历编写技巧,希望能和大家一起成长进步👊。【让现在的自己不再迷漫✨】
Stars: ✭ 308 (-27.53%)
Mutual labels:  memcached
Search Ads Web Service
Online search advertisement platform & Realtime Campaign Monitoring [Maybe Deprecated]
Stars: ✭ 30 (-92.94%)
Mutual labels:  memcached
Senparc.co2net
支持 .NET Framework & .NET Core 的公共基础扩展库
Stars: ✭ 289 (-32%)
Mutual labels:  memcached
Gnomock
Test your code without writing mocks with ephemeral Docker containers 📦 Setup popular services with just a couple lines of code ⏱️ No bash, no yaml, only code 💻
Stars: ✭ 398 (-6.35%)
Mutual labels:  memcached
Gobeansdb
Distributed object storage server from Douban Inc.
Stars: ✭ 351 (-17.41%)
Mutual labels:  memcached
Cache
Cache library
Stars: ✭ 310 (-27.06%)
Mutual labels:  memcached

memcached

An interface to the libmemcached C client. Build Status

License

Copyright 2009-2013 Cloudburst, LLC. Licensed under the AFL 3. See the included LICENSE file. Portions copyright 2007-2009 TangentOrg, Brian Aker, licensed under the BSD license, and used with permission.

Features

  • clean API
  • robust access to all memcached features
  • SASL support for the binary protocol
  • multiple hashing modes, including consistent hashing
  • ludicrous speed, including optional pipelined IO with no_reply

The memcached library wraps the pure-C libmemcached client via SWIG.

Installation

You need Ruby 1.8.7 or Ruby 1.9.2. Other versions may work, but are not guaranteed. You also need the libsasl2-dev and gettext libraries, which should be provided through your system's package manager.

Install the gem: sudo gem install memcached --no-rdoc --no-ri

Usage

Start a local networked memcached server: $ memcached -p 11211 &

Now, in Ruby, require the library and instantiate a Memcached object at a global level:

require 'memcached'
$cache = Memcached.new("localhost:11211")

Now you can set things and get things:

value = 'hello'
$cache.set 'test', value
$cache.get 'test' #=> "hello"

You can set with an expiration timeout:

value = 'hello'
$cache.set 'test', value, 1
sleep(2)
$cache.get 'test' #=> raises Memcached::NotFound

You can get multiple values at once:

value = 'hello'
$cache.set 'test', value
$cache.set 'test2', value
$cache.get ['test', 'test2', 'missing']
  #=> {"test" => "hello", "test2" => "hello"}

You can set a counter and increment it. Note that you must initialize it with an integer, encoded as an unmarshalled ASCII string:

start = 1
$cache.set 'counter', start.to_s, 0, false
$cache.increment 'counter' #=> 2
$cache.increment 'counter' #=> 3
$cache.get('counter', false).to_i #=> 3

You can get some server stats:

$cache.stats #=> {..., :bytes_written=>[62], :version=>["1.2.4"] ...}

Note that the API is not the same as that of Ruby-MemCache or memcache-client. In particular, nil is a valid record value. Memcached#get does not return nil on failure, rather it raises Memcached::NotFound. This is consistent with the behavior of memcached itself. For example:

$cache.set 'test', nil
$cache.get 'test' #=> nil
$cache.delete 'test'
$cache.get 'test' #=> raises Memcached::NotFound

Rails 3 and 4

Use memcached_store gem to integrate ActiveSupport cache store and memcached gem

Pipelining

Pipelining updates is extremely effective in memcached, leading to more than 25x write throughput than the default settings. Use the following options to enable it:

:no_block => true,
:buffer_requests => true,
:noreply => true,
:binary_protocol => false

Currently #append, #prepend, #set, and #delete are pipelined. Note that when you perform a read, all pending writes are flushed to the servers.

Threading

memcached is threadsafe, but each thread requires its own Memcached instance. Create a global Memcached, and then call Memcached#clone each time you spawn a thread.

thread = Thread.new do
  cache = $cache.clone
  # Perform operations on cache, not $cache
  cache.set 'example', 1
  cache.get 'example'
end

# Join the thread so that exceptions don't get lost
thread.join

Legacy applications

There is a compatibility wrapper for legacy applications called Memcached::Rails.

Benchmarks

memcached, correctly configured, is at least twice as fast as memcache-client and dalli. See link:BENCHMARKS for details.

Reporting problems

The support forum is here.

Patches and contributions are very welcome. Please note that contributors are required to assign copyright for their additions to Cloudburst, LLC.

Further resources

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].