Module: Moneta

### Home Classes Methods

### In Files

- lib/moneta.rb
- lib/moneta/adapters/activerecord.rb
- lib/moneta/adapters/cassandra.rb
- lib/moneta/adapters/client.rb
- lib/moneta/adapters/cookie.rb
- lib/moneta/adapters/couch.rb
- lib/moneta/adapters/datamapper.rb
- lib/moneta/adapters/daybreak.rb
- lib/moneta/adapters/dbm.rb
- lib/moneta/adapters/file.rb
- lib/moneta/adapters/fog.rb
- lib/moneta/adapters/gdbm.rb
- lib/moneta/adapters/hbase.rb
- lib/moneta/adapters/kyotocabinet.rb
- lib/moneta/adapters/leveldb.rb
- lib/moneta/adapters/lmdb.rb
- lib/moneta/adapters/localmemcache.rb
- lib/moneta/adapters/lruhash.rb
- lib/moneta/adapters/memcached.rb
- lib/moneta/adapters/memcached/dalli.rb
- lib/moneta/adapters/memcached/native.rb
- lib/moneta/adapters/memory.rb
- lib/moneta/adapters/mongo.rb
- lib/moneta/adapters/mongo/base.rb
- lib/moneta/adapters/mongo/moped.rb
- lib/moneta/adapters/mongo/official.rb
- lib/moneta/adapters/null.rb
- lib/moneta/adapters/pstore.rb
- lib/moneta/adapters/redis.rb
- lib/moneta/adapters/restclient.rb
- lib/moneta/adapters/riak.rb
- lib/moneta/adapters/sdbm.rb
- lib/moneta/adapters/sequel.rb
- lib/moneta/adapters/sqlite.rb
- lib/moneta/adapters/tdb.rb
- lib/moneta/adapters/tokyocabinet.rb
- lib/moneta/adapters/tokyotyrant.rb
- lib/moneta/adapters/yaml.rb
- lib/moneta/builder.rb
- lib/moneta/cache.rb
- lib/moneta/expires.rb
- lib/moneta/lock.rb
- lib/moneta/logger.rb
- lib/moneta/mixins.rb
- lib/moneta/optionmerger.rb
- lib/moneta/pool.rb
- lib/moneta/proxy.rb
- lib/moneta/server.rb
- lib/moneta/shared.rb
- lib/moneta/stack.rb
- lib/moneta/synchronize.rb
- lib/moneta/transformer.rb
- lib/moneta/transformer/config.rb
- lib/moneta/transformer/helper.rb
- lib/moneta/utils.rb
- lib/moneta/version.rb
- lib/moneta/weak.rb
- lib/moneta/wrapper.rb

### Namespace

- MODULE Moneta::Adapters
- MODULE Moneta::CreateSupport
- MODULE Moneta::Defaults
- MODULE Moneta::ExpiresSupport
- MODULE Moneta::HashAdapter
- MODULE Moneta::IncrementSupport
- MODULE Moneta::OptionSupport
- MODULE Moneta::Utils
- CLASS Moneta::Builder
- CLASS Moneta::Cache
- CLASS Moneta::Expires
- CLASS Moneta::Lock
- CLASS Moneta::Logger
- CLASS Moneta::Mutex
- CLASS Moneta::OptionMerger
- CLASS Moneta::Pool
- CLASS Moneta::Proxy
- CLASS Moneta::Semaphore
- CLASS Moneta::Server
- CLASS Moneta::Shared
- CLASS Moneta::Stack
- CLASS Moneta::SynchronizePrimitive
- CLASS Moneta::Transformer
- CLASS Moneta::WeakCreate
- CLASS Moneta::WeakIncrement
- CLASS Moneta::Wrapper

### Methods

- ::build
- ::new

### Files

- LICENSE

### Class/Module Index

Quicksearch

- Moneta
- Moneta::Adapters
- Moneta::Adapters::ActiveRecord
- Moneta::Adapters::Cassandra
- Moneta::Adapters::Client
- Moneta::Adapters::Cookie
- Moneta::Adapters::Couch
- Moneta::Adapters::DBM
- Moneta::Adapters::DataMapper
- Moneta::Adapters::DataMapper::Store
- Moneta::Adapters::Daybreak
- Moneta::Adapters::File
- Moneta::Adapters::Fog
- Moneta::Adapters::GDBM
- Moneta::Adapters::HBase
- Moneta::Adapters::KyotoCabinet
- Moneta::Adapters::LMDB
- Moneta::Adapters::LRUHash
- Moneta::Adapters::LRUHash::Entry
- Moneta::Adapters::LevelDB
- Moneta::Adapters::LocalMemCache
- Moneta::Adapters::MemcachedDalli
- Moneta::Adapters::MemcachedNative
- Moneta::Adapters::Memory
- Moneta::Adapters::MongoBase
- Moneta::Adapters::MongoMoped
- Moneta::Adapters::MongoOfficial
- Moneta::Adapters::Null
- Moneta::Adapters::PStore
- Moneta::Adapters::Redis
- Moneta::Adapters::RestClient
- Moneta::Adapters::Riak
- Moneta::Adapters::SDBM
- Moneta::Adapters::Sequel
- Moneta::Adapters::Sqlite
- Moneta::Adapters::TDB
- Moneta::Adapters::TokyoCabinet
- Moneta::Adapters::TokyoTyrant
- Moneta::Adapters::YAML
- Moneta::Builder
- Moneta::Cache
- Moneta::Cache::DSL
- Moneta::CreateSupport
- Moneta::Defaults
- Moneta::Defaults::ClassMethods
- Moneta::Expires
- Moneta::ExpiresSupport
- Moneta::HashAdapter
- Moneta::IncrementSupport
- Moneta::Lock
- Moneta::Logger
- Moneta::Logger::Format
- Moneta::Mutex
- Moneta::OptionMerger
- Moneta::OptionSupport
- Moneta::Pool
- Moneta::Proxy
- Moneta::Semaphore
- Moneta::Server
- Moneta::Shared
- Moneta::Stack
- Moneta::Stack::DSL
- Moneta::SynchronizePrimitive
- Moneta::Transformer
- Moneta::Transformer::Helper
- Moneta::Utils
- Moneta::WeakCreate
- Moneta::WeakIncrement
- Moneta::Wrapper
- Rack
- Rack::Cache
- Rack::Cache::EntityStore
- Rack::Cache::EntityStore::MONETA
- Rack::Cache::EntityStore::Moneta
- Rack::Cache::MetaStore
- Rack::Cache::MetaStore::MONETA
- Rack::Cache::MetaStore::Moneta
- Rack::Cache::MonetaResolver
- Rack::MonetaCookies
- Rack::MonetaRest
- Rack::MonetaStore
- Rack::Session
- Rack::Session::Moneta
- ActionDispatch
- ActionDispatch::Session
- ActionDispatch::Session::MonetaStore
- ActiveSupport
- ActiveSupport::Cache
- ActiveSupport::Cache::MonetaStore

No matching classes.

# Moneta

### Constants

VERSION

  Moneta version number @api public

### Public Class Methods

build(&block) click to toggle source

Configure your own Moneta proxy stack

@yieldparam Builder block @return [Moneta store] newly created Moneta store

@example Moneta builder

    Moneta.build do
      use :Expires
      adapter :Memory
    end

@api public

    # File lib/moneta.rb, line 147
    def self.build(&block)
      Builder.new(&block).build.last
    end

new(name, options = {}) click to toggle source

Create new Moneta store with default proxies

This works in most cases if you don't want fine control over the proxy stack. It uses Marshal on the keys and values. Use Moneta#build if you want to have fine control!

@param [Symbol] name Name of adapter (See Moneta::Adapters) @param [Hash] options @return [Moneta store] newly created Moneta store @option options [Boolean/Integer] :expires Ensure that store supports expiration by inserting

    {Expires} if the underlying adapter doesn't support it natively
    and set default expiration time

@option options [Boolean] :threadsafe (false) Ensure that the store is thread safe by inserting Moneta::Lock @option options [Boolean/Hash] :logger (false) Add logger to proxy stack (Hash is passed to logger as options) @option options [Boolean/Symbol] :compress (false) If true, compress value with zlib, or specify custom compress, e.g. :quicklz @option options [Symbol] :serializer (:marshal) Serializer used for key and value, disable with nil @option options [Symbol] :key_serializer (options) Serializer used for key, disable with nil @option options [Symbol] :value_serializer (options) Serializer used for value, disable with nil @option options [String] :prefix Key prefix used for namespacing (default none) @option options All other options passed to the adapter

Supported adapters:

- :HashFile (Store which spreads the entries using a md5 hash, e.g. cache/42/391dd7535aebef91b823286ac67fcd)

- :File (normal file store)

- :Memcached (Memcached store)

- ... (All other adapters from Moneta::Adapters)

@api public

    # File lib/moneta.rb, line 94
    def self.new(name, options = {})
      expires = options[:expires]
      options.delete(:expires) unless Integer === expires
      logger = options.delete(:logger)
      threadsafe = options.delete(:threadsafe)
      compress = options.delete(:compress)
      serializer = options.include?(:serializer) ? options.delete(:serializer) : :marshal
      key_serializer = options.include?(:key_serializer) ? options.delete(:key_serializer) : serializer
      value_serializer = options.include?(:value_serializer) ? options.delete(:value_serializer) : serializer
      transformer = { key: [key_serializer, :prefix], value: [value_serializer], prefix: options.delete(:prefix) }
      transformer[:value] << (Symbol === compress ? compress : :zlib) if compress
      raise ArgumentError, 'Name must be Symbol' unless Symbol === name
      case name
      when :Sequel
        # Sequel accept only base64 keys
        transformer[:key] << :base64
      when :ActiveRecord, :DataMapper, :Couch
        # DataMapper and AR accept only base64 keys and values
        transformer[:key] << :base64
        transformer[:value] << :base64
      when :PStore, :YAML, :Null
        # For PStore and YAML only the key has to be a string
        transformer.delete(:value) if transformer[:value] == [:marshal]
      when :HashFile
        # Use spreading hashes
        transformer[:key] << :md5 << :spread
        name = :File
      when :File, :Riak, :RestClient
        # Use escaping for file and HTTP interfaces
        transformer[:key] << :escape
      end
      a = Adapters.const_get(name).new(options)
      build do
        use :Logger, Hash === logger ? logger : {} if logger
        use :Expires, expires: options[:expires] if !a.supports?(:expires) && expires
        use :Transformer, transformer
        use :Lock if threadsafe
        adapter a
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.