alan 10 years ago
commit c144544eb4

1
.gitignore vendored

@ -21,3 +21,4 @@
.rbenv-gemsets
.DS_Store
public/api_doc/
/.metadata

@ -329,4 +329,11 @@ class AdminController < ApplicationController
format.html
end
end
#移动端版本管理
def mobile_version
@versions = PhoneAppVersion.reorder('created_at desc')
@new_version = PhoneAppVersion.new
end
end

@ -0,0 +1,3 @@
class PhoneAppVersion < ActiveRecord::Base
attr_accessible :description, :version
end

@ -33,7 +33,4 @@
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
<% end %>
<div>
</div>

@ -0,0 +1,56 @@
<h3><%= l(:label_mobile_version) %></h3>
<a href="javascript:void(0)" onclick="$('#new_version').slideToggle(400); ">发布新版本</a>
<div>
<form id="new_version" style="display: none">
</form>
</div>
<br/>
<div>当前版本:</div>
<table class="list">
<thead>
<tr>
<th><%=l(:label_version_number)%></th>
<th><%=l(:label_version_description)%></th>
</tr>
</thead>
<tbody>
<% if @versions.count > 0 %>
<tr class="<%= cycle("odd", "even") %>">
<td><%= @versions.first.version %></td>
<td align="center" style="width: 70%">
<%= @versions.first.description %>
</td>
</tr>
<% end %>
</tbody>
</table>
<br/>
<div>历史版本:</div>
<table class="list">
<thead>
<tr>
<th><%=l(:label_version_number)%></th>
<th><%=l(:label_version_description)%></th>
</tr>
</thead>
<tbody>
<% if @versions.count > 0 %>
<% for version in @versions %>
<tr class="<%= cycle("odd", "even") %>">
<td><%= version.version %></td>
<td align="center" style="width: 70%">
<%= version.description %>
</td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<!-- <div class="pagination"><#%= pagination_links_full @role_pages %></div> -->
<% html_title(l(:label_mobile_version)) -%>

@ -0,0 +1,20 @@
<div id="tags_show">
<%= render :partial => "tags/tag_name",:locals => {:obj => obj,:non_list_all => false ,:object_flag => object_flag} %>
</div>
<% if User.current.logged? %>
<span> <%= toggle_link ("+ 添加标签"), 'put-tag-form', {:focus => 'tags_name'} %> </span>
<% end %>
<div id="put-tag-form" style="display: none">
<%= form_for "tag_for_save",:remote=>true,:url=>tag_path,
:update => "tags_show",
:complete => '$("#put-tag-form").slideUp();' do |f| %>
<%= f.text_field :name ,:id => "tags_name",:size=>"20",
:require=>true,
:maxlength => Setting.tags_max_length,
:minlength=>Setting.tags_min_length %>
<%= f.text_field :object_id,:value=> obj.id,:style=>"display:none"%>
<%= f.text_field :object_flag,:value=> object_flag,:style=>"display:none"%>
<a href="#" onclick='$("#tags_name").parent().submit();' type="button" class="submit f_l"></a>
<% end %>
</div>

@ -555,6 +555,8 @@ zh:
label_organizer_name: 主办单位名称
label_web_footer_description: 页脚内容
label_cooperation_compnay: 合作单位
label_version_number: 版本号
label_version_description: 版本描述
label_web_footer_cooperation_compnay: 网站页脚合作单位
label_new_company: 添加合作单位
label_edit_company: 编辑合作单位
@ -1080,6 +1082,7 @@ zh:
label_project_copy_notifications: 复制项目时发送邮件通知
label_principal_search: "搜索用户或组:"
label_user_search: "搜索用户:"
label_mobile_version: "移动端版本管理"
button_check_all: 全选
button_uncheck_all: 清除

@ -641,6 +641,7 @@ RedmineApp::Application.routes.draw do
match 'admin/contest_page_made', as: :contest_page_made
match 'admin/web_footer_made', as: :web_footer_made
match 'admin/enterprise_page_made', as: :enterprise_page_made
match 'admin/mobile_version', as: :mobile_version
match 'admin/search', :via => [:get, :post]
match 'admin/plugins', :via => :get
match 'admin/info', :via => :get

@ -0,0 +1,10 @@
class CreatePhoneAppVersions < ActiveRecord::Migration
def change
create_table :phone_app_versions do |t|
t.string :version
t.text :description
t.timestamps
end
end
end

@ -11,7 +11,11 @@
#
# It's strongly recommended to check this file into your version control system.
<<<<<<< HEAD
ActiveRecord::Schema.define(:version => 20150305081132) do
=======
ActiveRecord::Schema.define(:version => 20150305011359) do
>>>>>>> 001b8bb1120fadea713d280e7d5bbabf7f5e57b8
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -815,11 +819,19 @@ ActiveRecord::Schema.define(:version => 20150305011359) do
t.integer "project_id"
end
<<<<<<< HEAD
create_table "phone_app_versions", :force => true do |t|
t.string "version"
t.text "description"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
=======
create_table "organizations", :force => true do |t|
t.string "name"
t.string "logo_link"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
>>>>>>> 001b8bb1120fadea713d280e7d5bbabf7f5e57b8
end
create_table "poll_answers", :force => true do |t|

@ -0,0 +1,13 @@
lib/dalli.rb b1fd9d39df06608fcae5bcf46e9940f95b186d22
lib/dalli/ring.rb e2cd42d8b963e669e2c8a83791fa56ec94f9ec55
lib/dalli/server.rb a42d734f9b3d654886c86f04fb4f0352e7147b1e
lib/dalli/client.rb 11afa0d702c68a151c87ea6e7ccdc863cf03884f
lib/dalli/socket.rb 18b7243332ec2dafa9a17c195944e321b684e67e
lib/dalli/options.rb d7ecb4c52b4ae2b222f319813234297e0951f82a
lib/dalli/version.rb fff3231b7f52d7fa1dabb78bf1f67dcef95c5378
lib/dalli/railtie.rb 63dc0fe85790a10225e867774f2c611d1c1ac46c
lib/dalli/compressor.rb 13b0cf3f607bd8bc9f969679b0b6e9dcb0a059d7
lib/dalli/cas/client.rb 983ded7ec738ed4502658150123e9c5ad7e3faa1
lib/rack/session/dalli.rb 2696ad72e8f9d7f5ceb232db0c8d9a8916192edb
lib/active_support/cache/dalli_store.rb 010d880e0f297d92b26c8f44e446add9d4fedfa2
lib/action_dispatch/middleware/session/dalli_store.rb 62236273ea28a91502871f31aa600e038358931a

@ -0,0 +1,12 @@
source 'https://rubygems.org'
gemspec
gem 'rake'
gem 'kgio', :platform => :mri
gem 'appraisal'
gem 'connection_pool'
group :test do
gem 'simplecov'
end

File diff suppressed because it is too large Load Diff

@ -0,0 +1,20 @@
Copyright (c) Mike Perham
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -0,0 +1,42 @@
Performance
====================
Caching is all about performance, so I carefully track Dalli performance to ensure no regressions.
You can optionally use kgio to give Dalli a 10-20% performance boost: `gem install kgio`.
Note I've added some benchmarks over time to Dalli that the other libraries don't necessarily have.
memcache-client
---------------
Testing 1.8.5 with ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
user system total real
set:plain:memcache-client 1.860000 0.310000 2.170000 ( 2.188030)
set:ruby:memcache-client 1.830000 0.290000 2.120000 ( 2.130212)
get:plain:memcache-client 1.830000 0.340000 2.170000 ( 2.176156)
get:ruby:memcache-client 1.900000 0.330000 2.230000 ( 2.235045)
multiget:ruby:memcache-client 0.860000 0.120000 0.980000 ( 0.987348)
missing:ruby:memcache-client 1.630000 0.320000 1.950000 ( 1.954867)
mixed:ruby:memcache-client 3.690000 0.670000 4.360000 ( 4.364469)
dalli
-----
Testing with Rails 3.2.1
Using kgio socket IO
Testing 2.0.0 with ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]
user system total real
mixed:rails:dalli 1.580000 0.570000 2.150000 ( 3.008839)
set:plain:dalli 0.730000 0.300000 1.030000 ( 1.567098)
setq:plain:dalli 0.520000 0.120000 0.640000 ( 0.634402)
set:ruby:dalli 0.800000 0.300000 1.100000 ( 1.640348)
get:plain:dalli 0.840000 0.330000 1.170000 ( 1.668425)
get:ruby:dalli 0.850000 0.330000 1.180000 ( 1.665716)
multiget:ruby:dalli 0.700000 0.260000 0.960000 ( 0.965423)
missing:ruby:dalli 0.720000 0.320000 1.040000 ( 1.511720)
mixed:ruby:dalli 1.660000 0.640000 2.300000 ( 3.320743)
mixedq:ruby:dalli 1.630000 0.510000 2.140000 ( 2.629734)
incr:ruby:dalli 0.270000 0.100000 0.370000 ( 0.547618)

@ -0,0 +1,224 @@
Dalli [![Build Status](https://secure.travis-ci.org/mperham/dalli.png)](http://travis-ci.org/mperham/dalli) [![Dependency Status](https://gemnasium.com/mperham/dalli.png)](https://gemnasium.com/mperham/dalli) [![Code Climate](https://codeclimate.com/github/mperham/dalli.png)](https://codeclimate.com/github/mperham/dalli)
=====
Dalli is a high performance pure Ruby client for accessing memcached servers. It works with memcached 1.4+ only as it uses the newer binary protocol. It should be considered a replacement for the memcache-client gem.
The name is a variant of Salvador Dali for his famous painting [The Persistence of Memory](http://en.wikipedia.org/wiki/The_Persistence_of_Memory).
![Persistence of Memory](http://www.virtualdali.com/assets/paintings/31PersistenceOfMemory.jpg)
Dalli's initial development was sponsored by [CouchBase](http://www.couchbase.com/). Many thanks to them!
Design
------------
I decided to write Dalli after maintaining memcache-client for two years for a few specific reasons:
0. The code is mostly old and gross. The bulk of the code is a single 1000 line .rb file.
1. It has a lot of options that are infrequently used which complicate the codebase.
2. The implementation has no single point to attach monitoring hooks.
3. Uses the old text protocol, which hurts raw performance.
So a few notes. Dalli:
0. uses the exact same algorithm to choose a server so existing memcached clusters with TBs of data will work identically to memcache-client.
1. is approximately 20% faster than memcache-client (which itself was heavily optimized) in Ruby 1.9.2.
2. contains explicit "chokepoint" methods which handle all requests; these can be hooked into by monitoring tools (NewRelic, Rack::Bug, etc) to track memcached usage.
3. supports SASL for use in managed environments, e.g. Heroku.
4. provides proper failover with recovery and adjustable timeouts
Supported Ruby versions and implementations
------------------------------------------------
Dalli should work identically on:
* JRuby 1.6+
* Ruby 1.9.3+
* Rubinius 2.0
If you have problems, please enter an issue.
Installation and Usage
------------------------
Remember, Dalli **requires** memcached 1.4+. You can check the version with `memcached -h`. Please note that memcached that Mac OS X Snow Leopard ships with is 1.2.8 and won't work. Install 1.4.x using Homebrew with
brew install memcached
On Ubuntu you can install it by running:
apt-get install memcached
You can verify your installation using this piece of code:
```bash
gem install dalli
```
```ruby
require 'dalli'
options = { :namespace => "app_v1", :compress => true }
dc = Dalli::Client.new('localhost:11211', options)
dc.set('abc', 123)
value = dc.get('abc')
```
The test suite requires memcached 1.4.3+ with SASL enabled (brew install memcached --enable-sasl ; mv /usr/bin/memcached /usr/bin/memcached.old). Currently only supports the PLAIN mechanism.
Dalli has no runtime dependencies and never will. You can optionally install the 'kgio' gem to
give Dalli a 20-30% performance boost.
Usage with Rails 3.x and 4.x
---------------------------
In your Gemfile:
```ruby
gem 'dalli'
```
In `config/environments/production.rb`:
```ruby
config.cache_store = :dalli_store
```
Here's a more comprehensive example that sets a reasonable default for maximum cache entry lifetime (one day), enables compression for large values and namespaces all entries for this rails app. Remove the namespace if you have multiple apps which share cached values.
```ruby
config.cache_store = :dalli_store, 'cache-1.example.com', 'cache-2.example.com',
{ :namespace => NAME_OF_RAILS_APP, :expires_in => 1.day, :compress => true }
```
If your servers are specified in `ENV["MEMCACHE_SERVERS"]` (e.g. on Heroku when using a third-party hosted addon), simply provide `nil` for the servers:
```ruby
config.cache_store = :dalli_store, nil, { :namespace => NAME_OF_RAILS_APP, :expires_in => 1.day, :compress => true }
```
To use Dalli for Rails session storage that times out after 20 minutes, in `config/initializers/session_store.rb`:
For Rails >= 3.2.4:
```ruby
Rails.application.config.session_store ActionDispatch::Session::CacheStore, :expire_after => 20.minutes
```
For Rails 3.x:
```ruby
require 'action_dispatch/middleware/session/dalli_store'
Rails.application.config.session_store :dalli_store, :memcache_server => ['host1', 'host2'], :namespace => 'sessions', :key => '_foundation_session', :expire_after => 20.minutes
```
Dalli does not support Rails 2.x.
Multithreading and Rails
--------------------------
If you use Puma or another threaded app server, as of Dalli 2.7, you can use a pool
of Dalli clients with Rails to ensure the `Rails.cache` singleton does not become a
source of thread contention. You must add `gem 'connection_pool'` to your Gemfile and
add :pool\_size to your `dalli_store` config:
```ruby
config.cache_store = :dalli_store, 'cache-1.example.com', { :pool_size => 5 }
```
You can then use the Rails cache as normal or check out a Dalli client directly from the pool:
```ruby
Rails.cache.fetch('foo', :expires_in => 300) do
'bar'
end
Rails.cache.dalli.with do |client|
# client is a Dalli::Client instance which you can
# use ONLY within this block
end
```
Configuration
------------------------
Dalli::Client accepts the following options. All times are in seconds.
**expires_in**: Global default for key TTL. Default is 0, which means no expiry.
**failover**: Boolean, if true Dalli will failover to another server if the main server for a key is down.
**compress**: Boolean, if true Dalli will gzip-compress values larger than 1K.
**compression_min_size**: Minimum value byte size for which to attempt compression. Default is 1K.
**compression_max_size**: Maximum value byte size for which to attempt compression. Default is unlimited.
**serializer**: The serializer to use for objects being stored (ex. JSON).
Default is Marshal.
**socket_timeout**: Timeout for all socket operations (connect, read, write). Default is 0.5.
**socket_max_failures**: When a socket operation fails after socket_timeout, the same operation is retried. This is to not immediately mark a server down when there's a very slight network problem. Default is 2.
**socket_failure_delay**: Before retrying a socket operation, the process sleeps for this amount of time. Default is 0.01. Set to nil for no delay.
**down_retry_delay**: When a server has been marked down due to many failures, the server will be checked again for being alive only after this amount of time. Don't set this value to low, otherwise each request which tries the failed server might hang for the maximum **socket_timeout**. Default is 1 second.
**value_max_bytes**: The maximum size of a value in memcached. Defaults to 1MB, this can be increased with memcached's -I parameter. You must also configure Dalli to allow the larger size here.
**username**: The username to use for authenticating this client instance against a SASL-enabled memcached server. Heroku users should not need to use this normally.
**password**: The password to use for authenticating this client instance against a SASL-enabled memcached server. Heroku users should not need to use this normally.
**keepalive**: Boolean. If true, Dalli will enable keep-alive for socket connections. Default is true.
**compressor**: The compressor to use for objects being stored.
Default is zlib, implemented under `Dalli::Compressor`.
If serving compressed data using nginx's HttpMemcachedModule, set `memcached_gzip_flag 2` and use `Dalli::GzipCompressor`
Features and Changes
------------------------
By default, Dalli is thread-safe. Disable thread-safety at your own peril.
Dalli does not need anything special in Unicorn/Passenger since 2.0.4.
It will detect sockets shared with child processes and gracefully reopen the
socket.
Note that Dalli does not require ActiveSupport or Rails. You can safely use it in your own Ruby projects.
[View the Client API](http://www.rubydoc.info/github/mperham/dalli/Dalli/Client)
Helping Out
-------------
If you have a fix you wish to provide, please fork the code, fix in your local project and then send a pull request on github. Please ensure that you include a test which verifies your fix and update History.md with a one sentence description of your fix so you get credit as a contributor.
We're not accepting new compressors. They are trivial to add in an initializer. See #385 (LZ4), #406 (Snappy)
Thanks
------------
Eric Wong - for help using his [kgio](http://unicorn.bogomips.org/kgio/index.html) library.
Brian Mitchell - for his remix-stash project which was helpful when implementing and testing the binary protocol support.
[CouchBase](http://couchbase.com) - for their project sponsorship
Author
----------
Mike Perham, [mikeperham.com](http://mikeperham.com), [@mperham](http://twitter.com/mperham)
Copyright
-----------
Copyright (c) Mike Perham. See LICENSE for details.

@ -0,0 +1,42 @@
require 'appraisal'
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'test'
test.pattern = 'test/**/test_*.rb'
test.warning = true
test.verbose = true
end
Rake::TestTask.new(:bench) do |test|
test.libs << 'test'
test.pattern = 'test/benchmark_test.rb'
end
begin
require 'metric_fu'
MetricFu::Configuration.run do |config|
config.rcov[:rcov_opts] << "-Itest:lib"
end
rescue LoadError
end
task :default => :test
task :test_all do
system('rake test RAILS_VERSION="~> 3.0.0"')
system('rake test RAILS_VERSION=">= 3.0.0"')
end
# 'gem install rdoc' to upgrade RDoc if this is giving you errors
begin
require 'rdoc/task'
RDoc::Task.new do |rd|
rd.rdoc_files.include("lib/**/*.rb")
end
rescue LoadError
puts "Unable to load rdoc, run 'gem install rdoc' to fix this."
end
require 'rake/clean'
CLEAN.include "**/*.rbc"
CLEAN.include "**/.DS_Store"

@ -0,0 +1,29 @@
require './lib/dalli/version'
Gem::Specification.new do |s|
s.name = %q{dalli}
s.version = Dalli::VERSION
s.license = "MIT"
s.authors = ["Mike Perham"]
s.description = %q{High performance memcached client for Ruby}
s.email = %q{mperham@gmail.com}
s.files = Dir.glob("lib/**/*") + [
"LICENSE",
"README.md",
"History.md",
"Rakefile",
"Gemfile",
"dalli.gemspec",
"Performance.md",
]
s.homepage = %q{http://github.com/mperham/dalli}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
s.summary = %q{High performance memcached client for Ruby}
s.test_files = Dir.glob("test/**/*")
s.add_development_dependency(%q<minitest>, [">= 4.2.0"])
s.add_development_dependency(%q<mocha>, [">= 0"])
s.add_development_dependency(%q<rails>, ["~> 4"])
end

@ -0,0 +1,81 @@
require 'active_support/cache'
require 'action_dispatch/middleware/session/abstract_store'
require 'dalli'
# Dalli-based session store for Rails 3.0.
module ActionDispatch
module Session
class DalliStore < AbstractStore
def initialize(app, options = {})
# Support old :expires option
options[:expire_after] ||= options[:expires]
super
@default_options = { :namespace => 'rack:session' }.merge(@default_options)
@pool = options[:cache] || begin
Dalli::Client.new(
@default_options[:memcache_server], @default_options)
end
@namespace = @default_options[:namespace]
@raise_errors = !!@default_options[:raise_errors]
super
end
def reset
@pool.reset
end
private
def get_session(env, sid)
sid = generate_sid unless sid and !sid.empty?
begin
session = @pool.get(sid) || {}
rescue Dalli::DalliError => ex
# re-raise ArgumentError so Rails' session abstract_store.rb can autoload any missing models
raise ArgumentError, ex.message if ex.message =~ /unmarshal/
Rails.logger.warn("Session::DalliStore#get: #{ex.message}")
session = {}
end
[sid, session]
end
def set_session(env, sid, session_data, options = nil)
options ||= env[ENV_SESSION_OPTIONS_KEY]
expiry = options[:expire_after]
@pool.set(sid, session_data, expiry)
sid
rescue Dalli::DalliError
Rails.logger.warn("Session::DalliStore#set: #{$!.message}")
raise if @raise_errors
false
end
def destroy_session(env, session_id, options)
begin
@pool.delete(session_id)
rescue Dalli::DalliError
Rails.logger.warn("Session::DalliStore#destroy_session: #{$!.message}")
raise if @raise_errors
end
return nil if options[:drop]
generate_sid
end
def destroy(env)
if sid = current_session_id(env)
@pool.delete(sid)
end
rescue Dalli::DalliError
Rails.logger.warn("Session::DalliStore#destroy: #{$!.message}")
raise if @raise_errors
false
end
end
end
end

File diff suppressed because it is too large Load Diff

@ -0,0 +1,46 @@
require 'dalli/compressor'
require 'dalli/client'
require 'dalli/ring'
require 'dalli/server'
require 'dalli/socket'
require 'dalli/version'
require 'dalli/options'
require 'dalli/railtie' if defined?(::Rails::Railtie)
module Dalli
# generic error
class DalliError < RuntimeError; end
# socket/server communication error
class NetworkError < DalliError; end
# no server available/alive error
class RingError < DalliError; end
# application error in marshalling serialization
class MarshalError < DalliError; end
# application error in marshalling deserialization or decompression
class UnmarshalError < DalliError; end
def self.logger
@logger ||= (rails_logger || default_logger)
end
def self.rails_logger
(defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger) ||
(defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER.respond_to?(:debug) && RAILS_DEFAULT_LOGGER)
end
def self.default_logger
require 'logger'
l = Logger.new(STDOUT)
l.level = Logger::INFO
l
end
def self.logger=(logger)
@logger = logger
end
end
if defined?(RAILS_VERSION) && RAILS_VERSION < '3'
raise Dalli::DalliError, "Dalli #{Dalli::VERSION} does not support Rails version < 3.0"
end

@ -0,0 +1,58 @@
require 'dalli/client'
module Dalli
class Client
##
# Get the value and CAS ID associated with the key. If a block is provided,
# value and CAS will be passed to the block.
def get_cas(key)
(value, cas) = perform(:cas, key)
value = (!value || value == 'Not found') ? nil : value
if block_given?
yield value, cas
else
[value, cas]
end
end
##
# Fetch multiple keys efficiently, including available metadata such as CAS.
# If a block is given, yields key/data pairs one a time. Data is an array:
# [value, cas_id]
# If no block is given, returns a hash of
# { 'key' => [value, cas_id] }
def get_multi_cas(*keys)
if block_given?
get_multi_yielder(keys) {|*args| yield(*args)}
else
Hash.new.tap do |hash|
get_multi_yielder(keys) {|k, data| hash[k] = data}
end
end
end
##
# Set the key-value pair, verifying existing CAS.
# Returns the resulting CAS value if succeeded, and falsy otherwise.
def set_cas(key, value, cas, ttl=nil, options=nil)
ttl ||= @options[:expires_in].to_i
perform(:set, key, value, ttl, cas, options)
end
##
# Conditionally add a key/value pair, verifying existing CAS, only if the
# key already exists on the server. Returns the new CAS value if the
# operation succeeded, or falsy otherwise.
def replace_cas(key, value, cas, ttl=nil, options=nil)
ttl ||= @options[:expires_in].to_i
perform(:replace, key, value, ttl, cas, options)
end
# Delete a key/value pair, verifying existing CAS.
# Returns true if succeeded, and falsy otherwise.
def delete_cas(key, cas=0)
perform(:delete, key, cas)
end
end
end

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save