/usr/lib/ruby/vendor_ruby/moneta.rb is in ruby-moneta 0.7.20-2.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | module Moneta
autoload :Builder, 'moneta/builder'
autoload :Cache, 'moneta/cache'
autoload :CreateSupport, 'moneta/mixins'
autoload :Defaults, 'moneta/mixins'
autoload :ExpiresSupport, 'moneta/mixins'
autoload :Expires, 'moneta/expires'
autoload :HashAdapter, 'moneta/mixins'
autoload :IncrementSupport, 'moneta/mixins'
autoload :Lock, 'moneta/lock'
autoload :Logger, 'moneta/logger'
autoload :Mutex, 'moneta/synchronize'
autoload :OptionMerger, 'moneta/optionmerger'
autoload :OptionSupport, 'moneta/mixins'
autoload :Pool, 'moneta/pool'
autoload :Proxy, 'moneta/proxy'
autoload :Semaphore, 'moneta/synchronize'
autoload :Server, 'moneta/server'
autoload :Shared, 'moneta/shared'
autoload :Stack, 'moneta/stack'
autoload :Transformer, 'moneta/transformer'
autoload :Utils, 'moneta/utils'
autoload :WeakCreate, 'moneta/weak'
autoload :WeakIncrement, 'moneta/weak'
autoload :Wrapper, 'moneta/wrapper'
module Adapters
autoload :ActiveRecord, 'moneta/adapters/activerecord'
autoload :Cassandra, 'moneta/adapters/cassandra'
autoload :Client, 'moneta/adapters/client'
autoload :Cookie, 'moneta/adapters/cookie'
autoload :Couch, 'moneta/adapters/couch'
autoload :Daybreak, 'moneta/adapters/daybreak'
autoload :DBM, 'moneta/adapters/dbm'
autoload :DataMapper, 'moneta/adapters/datamapper'
autoload :File, 'moneta/adapters/file'
autoload :Fog, 'moneta/adapters/fog'
autoload :GDBM, 'moneta/adapters/gdbm'
autoload :HBase, 'moneta/adapters/hbase'
autoload :LRUHash, 'moneta/adapters/lruhash'
autoload :KyotoCabinet, 'moneta/adapters/kyotocabinet'
autoload :LevelDB, 'moneta/adapters/leveldb'
autoload :LMDB, 'moneta/adapters/lmdb'
autoload :LocalMemCache, 'moneta/adapters/localmemcache'
autoload :Memcached, 'moneta/adapters/memcached'
autoload :MemcachedDalli, 'moneta/adapters/memcached/dalli'
autoload :MemcachedNative, 'moneta/adapters/memcached/native'
autoload :Memory, 'moneta/adapters/memory'
autoload :Mongo, 'moneta/adapters/mongo'
autoload :Null, 'moneta/adapters/null'
autoload :PStore, 'moneta/adapters/pstore'
autoload :Redis, 'moneta/adapters/redis'
autoload :RestClient, 'moneta/adapters/restclient'
autoload :Riak, 'moneta/adapters/riak'
autoload :SDBM, 'moneta/adapters/sdbm'
autoload :Sequel, 'moneta/adapters/sequel'
autoload :Sqlite, 'moneta/adapters/sqlite'
autoload :TDB, 'moneta/adapters/tdb'
autoload :TokyoCabinet, 'moneta/adapters/tokyocabinet'
autoload :TokyoTyrant, 'moneta/adapters/tokyotyrant'
autoload :YAML, 'moneta/adapters/yaml'
end
# 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]) Serializer used for key, disable with nil
# @option options [Symbol] :value_serializer (options[:serializer]) 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
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
# 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
def self.build(&block)
Builder.new(&block).build.last
end
end
|