Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: arthurnn/memcached
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: github/memcached
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: github
Choose a head ref

Commits on Apr 1, 2016

  1. Fix warning: instance variable @no_backtrace not initialized

    - memcached/lib/memcached/exceptions.rb:52: warning: instance variable @no_backtrace not initialized
    - memcached/lib/memcached/exceptions.rb:61: warning: instance variable @no_backtrace not initialized
    hirocaster committed Apr 1, 2016
    Copy the full SHA
    db975bc View commit details
  2. Fix warning: assigned but unused variable - flags

    - memcached/lib/memcached/experimental.rb:25: warning: assigned but unused variable - flags
    hirocaster committed Apr 1, 2016
    Copy the full SHA
    ffcf16d View commit details
  3. Fix warning: assigned but unused variable

    - test/unit/memcached_experimental_test.rb:92: warning: assigned but unused variable - result
    - test/unit/memcached_experimental_test.rb:122: warning: assigned but unused variable - result
    - test/unit/memcached_experimental_test.rb:176: warning: assigned but unused variable - result
    - test/unit/memcached_experimental_test.rb:196: warning: assigned but unused variable - result
    - test/unit/memcached_experimental_test.rb:194: warning: assigned but unused variable - value
    - test/unit/memcached_test.rb:277: warning: assigned but unused variable - result
    - test/unit/memcached_test.rb:295: warning: assigned but unused variable - result
    - test/unit/memcached_test.rb:302: warning: assigned but unused variable - result
    - test/unit/memcached_test.rb:309: warning: assigned but unused variable - result
    - test/unit/memcached_test.rb:321: warning: assigned but unused variable - result
    - test/unit/memcached_test.rb:328: warning: assigned but unused variable - result
    - test/unit/memcached_test.rb:339: warning: assigned but unused variable - result
    - test/unit/memcached_test.rb:949: warning: assigned but unused variable - response
    - test/unit/memcached_test.rb:963: warning: assigned but unused variable - response
    hirocaster committed Apr 1, 2016
    Copy the full SHA
    881743d View commit details
  4. Copy the full SHA
    80be9f8 View commit details
  5. Copy the full SHA
    28edb1d View commit details
  6. Fix warning: shadowing outer local variable

    - memcached/lib/memcached/memcached.rb:637: warning: shadowing outer local variable - server
    - memcached/lib/memcached/memcached.rb:700: warning: shadowing outer local variable - key
    hirocaster committed Apr 1, 2016
    Copy the full SHA
    9629305 View commit details

Commits on Apr 6, 2021

  1. Copy the full SHA
    b72f5bd View commit details
  2. Copy the full SHA
    0aecf7c View commit details
  3. Copy the full SHA
    dd1671f View commit details
  4. Copy the full SHA
    3df868a View commit details

Commits on Apr 7, 2021

  1. Fix missing require for socket standard library

    Backport of commit from #185
    dylanahsmith committed Apr 7, 2021
    Copy the full SHA
    cefc16d View commit details
  2. CI: Migrate to Github Actions

    Backport of #186
    dylanahsmith committed Apr 7, 2021
    Copy the full SHA
    daca477 View commit details
  3. Copy the full SHA
    97cae52 View commit details
  4. Merge pull request #192 from dylanahsmith/1-0-stable-github-actions

    Fix tests and migrate to Github Actions
    dylanahsmith authored Apr 7, 2021
    Copy the full SHA
    c07f7e0 View commit details
  5. Merge pull request #167 from hirocaster/fix-warnings

    Fix warnings
    dylanahsmith authored Apr 7, 2021
    Copy the full SHA
    aa5e492 View commit details
  6. Copy the full SHA
    7982fa4 View commit details
  7. Fix a method redefined warnings by removing the replaced method

    The warning was
    
    .../lib/memcached/memcached.rb:653: warning: method redefined; discarding old set_credentials
    .../lib/memcached/auth.rb:8: warning: previous definition of set_credentials was here
    
    Also, define all the methods for this class together in the same file,
    since auth.rb is always required anyways.
    dylanahsmith committed Apr 7, 2021
    Copy the full SHA
    75a51d1 View commit details
  8. Fix a circular require warning by autoloading optional modules

    The warnings was
    
    .../lib/memcached/rails.rb:1: warning: .../lib/memcached/rails.rb:1: warning: loading in progress, circular require considered harmful - .../lib/memcached.rb
    dylanahsmith committed Apr 7, 2021
    Copy the full SHA
    f06a3cb View commit details
  9. Fix an instance variable not initialized warning

    The warning was
    
    test/unit/rails_test.rb:91: warning: instance variable @called not initialized
    dylanahsmith committed Apr 7, 2021
    Copy the full SHA
    4fcdc5e View commit details
  10. Merge pull request #194 from dylanahsmith/fix-remaining-warnings

    Fix remaining warnings
    dylanahsmith authored Apr 7, 2021
    Copy the full SHA
    e539074 View commit details

Commits on Apr 13, 2021

  1. Use rb_external_str_new_with_enc to reduce coupling to RString struct (

    …#199)
    
    Avoids a "RSTRING_PTR is returning NULL!!" warning on ruby 3
    dylanahsmith authored Apr 13, 2021
    Copy the full SHA
    68b89fa View commit details
  2. Remove support for JRuby 1.6's C extensions

    This was an experimental feature that was disabled in JRuby 1.7 and
    then removed.
    dylanahsmith committed Apr 13, 2021
    Copy the full SHA
    0f50dae View commit details
  3. Remove conditional compilation that isn't needed anymore

    We are no longer using OBJSETUP to create a ruby string and rubinius
    has rb_external_str_new_with_enc, so we can just unconditionally use
    that function now.
    dylanahsmith committed Apr 13, 2021
    Copy the full SHA
    5c7a8ba View commit details
  4. Copy the full SHA
    73a67c3 View commit details
  5. Merge pull request #200 from arthurnn/use-newer-swig

    Regenerate the Swig bindings using Swig 4
    dylanahsmith authored Apr 13, 2021
    Copy the full SHA
    4ab53a5 View commit details

Commits on Apr 14, 2021

  1. Remove broken ClientError retry logic that effectively did nothing (#198

    )
    
    Since the `!tries` check was never true (0 is truthy in ruby).
    dylanahsmith authored Apr 14, 2021
    Copy the full SHA
    5f1385a View commit details
  2. Remove experimental get_len method

    The tests for this method were getting skipped because the server
    doesn't actually support this command.  I'm not sure when it was
    supported. Support for this was already removed from libmemcached.
    Since it was experimental in this library, we may as well just remove
    it now.
    dylanahsmith committed Apr 14, 2021
    Copy the full SHA
    0a1bccc View commit details

Commits on Apr 15, 2021

  1. Deprecate Rlibmemcached and Memcached#get_from_last

    Since the libmemcached upgrade is a breaking change, so we can't keep
    the Rlibmemcached interface stable and memcached_get_from_last won't
    be available.
    dylanahsmith committed Apr 15, 2021
    Copy the full SHA
    b4783f9 View commit details

Commits on Apr 20, 2021

  1. Merge pull request #201 from arthurnn/1-0-stable-deprecations

    Add deprecations and remove an experimental method
    dylanahsmith authored Apr 20, 2021
    Copy the full SHA
    c2f5d8b View commit details

Commits on May 12, 2021

  1. Copy the full SHA
    c7514e4 View commit details

Commits on May 13, 2021

  1. Fix memory leak from use of rb_external_str_new_with_enc

    I thought rb_external_str_new_with_enc did what I wanted, which was to
    pass ownership of the C string allocation and have ruby free it when it
    was done with it.  However, it actually just copies the string contents
    like with rb_str_new.
    dylanahsmith committed May 13, 2021
    Copy the full SHA
    5944e82 View commit details
  2. Copy the full SHA
    e2fcf7c View commit details

Commits on May 14, 2021

  1. Merge pull request #202 from arthurnn/1-x-clean-vendor-before-touch

    Clean vendor files before touching all of them to avoid missing changes
    casperisfine authored May 14, 2021
    Copy the full SHA
    ba89a97 View commit details
  2. Copy the full SHA
    411ad06 View commit details

Commits on May 17, 2021

  1. Merge pull request #203 from arthurnn/1-0-stable-fix-leak

    Fix unreleased memory leak from use of rb_external_str_new_with_enc
    casperisfine authored May 17, 2021
    Copy the full SHA
    e15fd2e View commit details

Commits on May 26, 2021

  1. Merge pull request #204 from Shopify/backport-interupt-handling

    Patch libmemcached to handle EINTR in poll(2)
    casperisfine authored May 26, 2021
    Copy the full SHA
    34090ff View commit details

Commits on May 28, 2021

  1. Fix compilation errors

    Specifically the problem is that when libmemcached is compiled, it can't
    find libsasl.  Libsasl exists, but the function it's checking for on
    macOS has been deprecated and that causes a compiler error.  Since
    libmemcached is compiled without sasl support that makes the Ruby
    extension blow up.
    tenderlove authored and byroot committed May 28, 2021
    Copy the full SHA
    6222c5d View commit details

Commits on Jun 30, 2021

  1. Copy the full SHA
    09e7761 View commit details

Commits on Jan 12, 2022

  1. Copy the full SHA
    241c040 View commit details

Commits on Jan 14, 2022

  1. Copy the full SHA
    b1372bf View commit details

Commits on Jan 24, 2022

  1. Fix show_backtraces: false leaking Exception#cause

    This code was likely fine back when it was written against Ruby 1.9.3,
    but since then `Kernel#raise` now automatically attach the currently rescued error
    as the new exception `cause`.
    
    Since this code was re-raising the same instance over and once a `cause` was
    attached it would never be de-associated, which in some contrived scenario could
    leak to information leak across requests / test etc.
    
    I ran a benchmark and the fastest way to raise exception I could find is:
    
    ```ruby
    raise ErrorClass, "message".freeze, EMPTY_ARRAY, cause: nil
    ```
    byroot committed Jan 24, 2022
    Copy the full SHA
    a553ff0 View commit details

Commits on Jan 25, 2022

  1. Copy the full SHA
    deccb0b View commit details

Commits on Mar 21, 2022

  1. Copy the full SHA
    b453563 View commit details
  2. Only build libmemcached

    Avoids linking tests and other components inside vendored libmemcached
    jhawthorn committed Mar 21, 2022
    Copy the full SHA
    1ee5d0c View commit details
  3. Avoid overflowing stack with too many keys

    This fixes a "stack level too deep" issue where the number of keys is so great they will not fit on the stack during the function call.
    
    Co-Authored-By: Julian Tibble <tibbes@github.com>
    2 people authored and jhawthorn committed Mar 21, 2022
    Copy the full SHA
    21968f7 View commit details

Commits on Jul 9, 2024

  1. Copy the full SHA
    9429dfc View commit details
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
ruby:
- '2.5' # earliest supported
- '3.0' # latest release

steps:
- run: |
sudo apt-get update
sudo apt-get -y install memcached libsasl2-dev
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec ruby test/setup.rb
- run: bundle exec rake
- run: bundle exec rake install
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ pkg/*
*.l[ao]
*.[1,3]
.libs
ext/rlibmemcached/rlibmemcached_wrap.c.in
ext/mkmf.log
/vendor/libmemcached-*/build
/vendor/libmemcached-*/**/Makefile
1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ source 'https://rubygems.org'
gemspec

gem 'test-unit'
gem "stackprof"

group :benchmark do
gem "remix-stash", '~> 1.1.3'
36 changes: 22 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -6,23 +6,30 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (3.2.6)
i18n (~> 0.6)
multi_json (~> 1.0)
dalli (2.7.5)
i18n (0.6.0)
activesupport (6.1.3.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
concurrent-ruby (1.1.8)
dalli (2.7.11)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
memcache-client (1.8.5)
metaclass (0.0.4)
mocha (1.0.0)
metaclass (~> 0.0.1)
multi_json (1.3.6)
power_assert (0.2.7)
rake (0.9.2.2)
rake-compiler (0.9.5)
minitest (5.14.4)
mocha (1.12.0)
power_assert (2.0.0)
rake (13.0.3)
rake-compiler (1.1.1)
rake
remix-stash (1.1.3)
test-unit (3.1.5)
stackprof (0.2.17)
test-unit (3.4.0)
power_assert
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
zeitwerk (2.4.2)

PLATFORMS
ruby
@@ -36,7 +43,8 @@ DEPENDENCIES
rake
rake-compiler
remix-stash (~> 1.1.3)
stackprof
test-unit

BUNDLED WITH
1.10.6
2.1.4
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# memcached

An interface to the libmemcached C client.
[![Build Status](https://travis-ci.org/arthurnn/memcached.svg?branch=master)](https://travis-ci.org/arthurnn/memcached)
[![Build Status](https://github.com/arthurnn/memcached/workflows/CI/badge.svg?branch=1-0-stable)](https://github.com/arthurnn/memcached/actions?query=branch%3A1-0-stable)

## License

11 changes: 5 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -15,13 +15,12 @@ Rake::TestTask.new do |t|
end
task :default => [:compile, :test]

Rake::Task[:clean].enhance do
FileUtils.rm_rf(File.read(".gitignore").lines.flat_map { |l| Dir["**/#{l.chomp}"] })
end

task :swig do
run("swig -DLIBMEMCACHED_WITH_SASL_SUPPORT -Iext/rlibmemcached/libmemcached-0.32 -ruby -autorename -o ext/rlibmemcached/rlibmemcached_wrap.c.in ext/rlibmemcached/rlibmemcached.i", "Running SWIG")
swig_patches = {
"#ifndef RUBY_INIT_STACK" => "#ifdef __NEVER__" # Patching SWIG output for JRuby.
}.map{|pair| "s/#{pair.join('/')}/"}.join(';')
# sed has different syntax for inplace switch in BSD and GNU version, so using intermediate file
run("sed '#{swig_patches}' ext/rlibmemcached/rlibmemcached_wrap.c.in > ext/rlibmemcached/rlibmemcached_wrap.c", "Apply patches to SWIG output")
run("swig -DLIBMEMCACHED_WITH_SASL_SUPPORT -Ivendor/libmemcached-0.32 -ruby -autorename -o ext/rlibmemcached/rlibmemcached_wrap.c ext/rlibmemcached/rlibmemcached.i", "Running SWIG")
end

task :exceptions do
22 changes: 13 additions & 9 deletions ext/rlibmemcached/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'mkmf'
require 'rbconfig'
require 'fileutils'

unless find_header('sasl/sasl.h')
abort 'Please install SASL to continue. The package is called libsasl2-dev on Ubuntu and cyrus-sasl on Gentoo.'
@@ -11,7 +12,7 @@
SOLARIS_32 = RbConfig::CONFIG['target'] == "i386-pc-solaris2.10"
BSD = RbConfig::CONFIG['host_os'].downcase =~ /bsd/

$CFLAGS = "#{RbConfig::CONFIG['CFLAGS']} #{$CFLAGS}".gsub("$(cflags)", "").gsub("-fno-common", "").gsub("-Werror=declaration-after-statement", "")
$CFLAGS = "#{RbConfig::CONFIG['CFLAGS']} #{$CFLAGS}".gsub("$(cflags)", "").gsub("-fno-common", "").gsub("-Werror=declaration-after-statement", "").gsub("-Werror=undef", "").gsub("-Werror=shorten-64-to-32", "").gsub("-Werror=deprecated-declarations", "").gsub("-Werror=old-style-definition", "")
$CFLAGS << " -Os"
$CFLAGS << " -std=gnu99" if SOLARIS_32
$CFLAGS << " -I/usr/local/include" if BSD
@@ -20,9 +21,8 @@
$CXXFLAGS = "#{RbConfig::CONFIG['CXXFLAGS']} -std=gnu++98"
$CC = "CC=#{RbConfig::MAKEFILE_CONFIG["CC"].inspect}"

# JRuby's default configure options can't build libmemcached properly
LIBM_CFLAGS = defined?(JRUBY_VERSION) ? "-fPIC -g -O2" : $CFLAGS
LIBM_LDFLAGS = defined?(JRUBY_VERSION) ? "-fPIC -lsasl2 -lm" : $LDFLAGS
LIBM_CFLAGS = $CFLAGS
LIBM_LDFLAGS = $LDFLAGS

GMAKE_CMD = RbConfig::CONFIG['host_os'].downcase =~ /bsd|solaris/ ? "gmake" : "make"
TAR_CMD = SOLARIS_32 ? 'gtar' : 'tar'
@@ -38,14 +38,18 @@ def check_libmemcached
return if ENV["EXTERNAL_LIB"]

Dir.chdir(LIBMEMCACHED_DIR) do
Dir.mkdir("build") if !Dir.exists?("build")
build_folder = File.join(LIBMEMCACHED_DIR, "build")

# Cleanup any previously built files since the following touch all files command
# could make them seem rebuilt when there are changes that require recompiling them.
FileUtils.rm_rf("build")
run("#{GMAKE_CMD} clean 2>&1") if File.exist?("Makefile")
ts_now=Time.now.strftime("%Y%m%d%H%M.%S")
run("find . | xargs touch -t #{ts_now}", "Touching all files so autoconf doesn't run.")

Dir.mkdir("build")
build_folder = File.join(LIBMEMCACHED_DIR, "build")
run("env CFLAGS='-fPIC #{LIBM_CFLAGS}' LDFLAGS='-fPIC #{LIBM_LDFLAGS}' ./configure --prefix=#{build_folder} --libdir=#{build_folder}/lib --without-memcached --disable-shared --disable-utils --disable-dependency-tracking #{$CC} #{$EXTRA_CONF} 2>&1", "Configuring libmemcached.")
run("#{GMAKE_CMD} CXXFLAGS='#{$CXXFLAGS}' 2>&1")
run("#{GMAKE_CMD} install 2>&1")
run("cd libmemcached && #{GMAKE_CMD} CXXFLAGS='#{$CXXFLAGS}' 2>&1")
run("cd libmemcached && #{GMAKE_CMD} install 2>&1")


pcfile = File.join(LIBMEMCACHED_DIR, "build", "lib", "pkgconfig", "libmemcached.pc")
111 changes: 48 additions & 63 deletions ext/rlibmemcached/rlibmemcached.i
Original file line number Diff line number Diff line change
@@ -109,12 +109,16 @@
$result = UINT2NUM($1);
};

%typemap(in, numinputs=0, noblock=1) (const char **key, size_t *key_length) {
char *key_ptr$argnum;
size_t key_length_ptr$argnum;
$1 = &key_ptr$argnum;
$2 = &key_length_ptr$argnum;
}

// String for memcached_fetch
%typemap(in, numinputs=0) (char *key, size_t *key_length) {
char string[256];
size_t length = 0;
$1 = string;
$2 = &length;
%typemap(argout) (const char **key, size_t *key_length) {
rb_ary_push($result, rb_str_new(*$1, *$2));
};

// Strings with lengths
@@ -149,82 +153,63 @@
%include "libmemcached/memcached_touch.h"
%include "libmemcached/memcached_exist.h"

//// Custom C functions

VALUE rb_str_new_by_ref(char *ptr, long len);
%{
VALUE rb_str_new_by_ref(char *ptr, long len)
{
#ifdef OBJSETUP
NEWOBJ(str, struct RString);
OBJSETUP(str, rb_cString, T_STRING);
#ifdef RSTRING_NOEMBED
/* Ruby 1.9 */
str->as.heap.ptr = ptr;
str->as.heap.len = len;
str->as.heap.aux.capa = len + 1;
// Set STR_NOEMBED
FL_SET(str, FL_USER1);
#else
/* Ruby 1.8 */
str->ptr = ptr;
str->len = len;
str->aux.capa = 0;
#endif
#else
/* Rubinius, JRuby */
VALUE str = rb_str_new(ptr, len);
free(ptr);
#endif
return (VALUE)str;
}
%}

//// Manual wrappers

// Single get
VALUE memcached_get_rvalue(memcached_st *ptr, const char *key, size_t key_length, uint32_t *flags, memcached_return *error);
%{
VALUE memcached_get_rvalue(memcached_st *ptr, const char *key, size_t key_length, uint32_t *flags, memcached_return *error) {
size_t value_length = 0;
char *value = memcached_get(ptr, key, key_length, &value_length, flags, error);
return rb_str_new_by_ref(value, value_length);
};
%}

VALUE memcached_get_len_rvalue(memcached_st *ptr, const char *key, size_t key_length, uint32_t user_spec_len, uint32_t *flags, memcached_return *error);
%{
VALUE memcached_get_len_rvalue(memcached_st *ptr, const char *key, size_t key_length, uint32_t user_spec_len, uint32_t *flags, memcached_return *error) {
size_t value_length = 0;
char *value = memcached_get_len(ptr, key, key_length, user_spec_len, &value_length, flags, error);
return rb_str_new_by_ref(value, value_length);
};
%}

VALUE memcached_get_from_last_rvalue(memcached_st *ptr, const char *key, size_t key_length, uint32_t *flags, memcached_return *error);
%{
VALUE memcached_get_from_last_rvalue(memcached_st *ptr, const char *key, size_t key_length, uint32_t *flags, memcached_return *error) {
size_t value_length = 0;
char *value = memcached_get_from_last(ptr, key, key_length, &value_length, flags, error);
return rb_str_new_by_ref(value, value_length);
VALUE str = rb_str_new(value, value_length);
free(value);
return str;
};
%}

// Multi get
VALUE memcached_fetch_rvalue(memcached_st *ptr, char *key, size_t *key_length, uint32_t *flags, memcached_return *error);
VALUE memcached_fetch_rvalue(memcached_st *ptr, const char **key, size_t *key_length, uint32_t *flags, memcached_return *error);
%{
VALUE memcached_fetch_rvalue(memcached_st *ptr, char *key, size_t *key_length, uint32_t *flags, memcached_return *error) {
size_t value_length = 0;
VALUE memcached_fetch_rvalue(memcached_st *ptr, const char **key, size_t *key_length, uint32_t *flags, memcached_return *error) {
VALUE ary = rb_ary_new();
*key_length = 0;
if (error) *error = MEMCACHED_TIMEOUT; // timeouts leave error uninitialized
char *value = memcached_fetch(ptr, key, key_length, &value_length, flags, error);
VALUE str = rb_str_new_by_ref(value, value_length);

*error = MEMCACHED_TIMEOUT; // timeouts leave error uninitialized
memcached_result_st *result = memcached_fetch_result(ptr, &ptr->result, error);
VALUE str = Qnil;
if (result == NULL || *error != MEMCACHED_SUCCESS) {
*key = NULL;
*key_length = 0;
*flags = 0;
str = Qnil;
} else {
*key = memcached_result_key_value(result);
*key_length = memcached_result_key_length(result);
*flags = memcached_result_flags(result);
str = rb_str_new(memcached_result_value(result), memcached_result_length(result));
}
rb_ary_push(ary, str);
return ary;
};
%}

// Single get
VALUE memcached_get_rvalue(memcached_st *ptr, const char *key, size_t key_length, uint32_t *flags, memcached_return *error);
%{
VALUE memcached_get_rvalue(memcached_st *ptr, const char *key, size_t key_length, uint32_t *flags, memcached_return *error) {
*error = memcached_mget(ptr, &key, &key_length, 1);
if (*error != MEMCACHED_SUCCESS) {
return rb_ary_new_from_args(1, Qnil);
}
VALUE ret = memcached_fetch_rvalue(ptr, &key, &key_length, flags, error);
if (*error == MEMCACHED_END) {
*error = MEMCACHED_NOTFOUND;
} else {
memcached_return end_error;
memcached_fetch_result(ptr, &ptr->result, &end_error);
}
return ret;
};
%}

// Ruby isn't aware that the pointer is an array... there is probably a better way to do this
memcached_server_st *memcached_select_server_at(memcached_st *in_ptr, int index);
%{
Loading