Giter VIP home page Giter VIP logo

libmemcached_store's Introduction

LibmemcachedStore

An ActiveSupport cache store that uses the C-based libmemcached client through Evan Weaver's Ruby/SWIG wrapper, memcached. libmemcached is fast (fastest memcache client for Ruby), lightweight, and supports consistent hashing, non-blocking IO, and graceful server failover.

This cache is designed for Rails 3.2+ applications.

Prerequisites

You'll need the memcached gem installed:

gem install memcached

or in your Gemfile

gem 'memcached'

There are no other dependencies.

Installation

Just add to your Gemfile

gem 'libmemcached_store', '~> 0.7.1'

and you're set.

Usage

This is a drop-in replacement for the memcache store that ships with Rails. To enable, set the config.cache_store option to libmemcached_store in the config for your environment

config.cache_store = :libmemcached_store

If no servers are specified, localhost is assumed. You can specify a list of server addresses, either as hostnames or IP addresses, with or without a port designation. If no port is given, 11211 is assumed:

config.cache_store = :libmemcached_store, %w(cache-01 cache-02 127.0.0.1:11212)

Standard Rails cache store options can be used

config.cache_store = :libmemcached_store, '127.0.0.1:11211', {:compress => true, :expires_in => 3600}

More advanced options can be passed directly to the client

config.cache_store = :libmemcached_store, '127.0.0.1:11211', {:client => { :binary_protocol => true, :no_block => true }}

You can also use :libmemcached_store to store your application sessions

require 'action_dispatch/session/libmemcached_store'
config.session_store :libmemcached_store, :namespace => '_session', :expire_after => 1800

You can use :libmemcached_local_store if you want a local in-memory cache for each request

config.cache_store :libmemcached_local_store

Increment / Decrement only work on raw values:

Rails.cache.write 'x', '1', :raw => true
Rails.cache.increment 'x' # => 2
Rails.cache.decrement 'x' # => 1

Performance

Used with Rails, libmemcached_store is at least 1.5x faster than dalli. See BENCHMARKS for details

Props

Thanks to Brian Aker (http://tangent.org) for creating libmemcached, and Evan Weaver (http://blog.evanweaver.com) for the Ruby wrapper.

libmemcached_store's People

Contributors

ccocchi avatar grosser avatar packagethief avatar jstorimer avatar benhutton avatar staugaard avatar rakoth avatar evan avatar jeremy avatar mauriciopasquier avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.