Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not working, but simple Cache::Memcached request does #1

Open
zoot opened this issue Apr 10, 2013 · 8 comments
Open

Module not working, but simple Cache::Memcached request does #1

zoot opened this issue Apr 10, 2013 · 8 comments

Comments

@zoot
Copy link

zoot commented Apr 10, 2013

Hi David

I'm unable to get this module to work with Dancer2.

This Perl code read/writes to my Memcached instance perfectly:

#!/usr/bin/perl

use Cache::Memcached;

my $memd = Cache::Memcached->new();
$memd->set_servers(['/path/to/sessions.sock']);

print "set fruit=orange\n";
$memd->set('fruit', 'orange');

my $val = $memd->get('fruit');
printf("get fruit: %s\n", $val);

print "delete 'fruit'\n";
$memd->delete('fruit');

my $val = $memd->get('fruit');
printf("get fruit: %s\n", $val);

My Dancer2 app sessions work fine with:

session: Simple

or

session: JSON

but NOT with:

session: Memcached

engines:
  session:
    Memcached:
      memcached_servers: /path/to/sessions.sock

I ran both the test code above and the Dancer2 app as the same user, so definitely no permission issues there.

How can I debug this? I see Dancer2::Session::Memcached uses the same module as my stand-alone test script does (Cache::Memcached) so wondering why it doesn't work?

Dancer2 0.03
Dancer2::Session::Memcached 0.002

You mentioned that in D2, session destruction should be done using

context->destroy_session

Am I also supposed to use different session syntax when setting and getting session variables, when using this session module?

I'm using:

session user => 'zoot'; # set session variable
my $user = session('user'); # get session variable
@dagolden
Copy link
Contributor

Hi, Dale. Could you send me a stripped down application that demonstrates the problem? I'm going to ship a new Dancer2::Session::Memcached that fixes some test bugs, but I don't think they affect your case.

@zoot
Copy link
Author

zoot commented Apr 10, 2013

Thanks David

Here's an easy to install package to create the same environment I'm using.

wget http://filegooi.co.za/get2/984a80022b945e6981ac0f7bb8b82409/dancer2-json-vs-memcached-sessions.tar.gz
tar xzf dancer2-json-vs-memcached-sessions.tar.gz
cd demo
vim README
./install.sh

@zoot
Copy link
Author

zoot commented Apr 10, 2013

Sorry, there's a minor typo in the install script. This fixes it:

http://filegooi.co.za/get2/e374d9f89c10a0f464e6669b7903afc1/dancer2-json-vs-memcached-sessions.tar.gz

@zoot
Copy link
Author

zoot commented Apr 11, 2013

Here are details on Tokyo Tyrant's protocols:

http://fallabs.com/tokyotyrant/spex.html#protocol

More specifically, it states, about Memcached:

As for the memcached (ASCII) compatible protocol, the server implements the following commands; "set", "add", "replace", "get", "delete", "incr", "decr", "stats", "flush_all", "version", and "quit". "noreply" options of update commands are also supported. However, "flags", "exptime", and "cas unique" parameters are ignored.

@dagolden
Copy link
Contributor

Thanks. I can't get TT running on my Mac, so I'm getting a Linux VM in
shape to try it.

Have you tried regular memcached, not TT? It would be nice to know if it's
a general problem or a TT specific.

David

On Wed, Apr 10, 2013 at 7:13 PM, Dale Gallagher [email protected]:

Sorry, there's a minor typo in the install script. This fixes it:

http://filegooi.co.za/get2/e374d9f89c10a0f464e6669b7903afc1/dancer2-json-vs-memcached-sessions.tar.gz


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-16208257
.

David Golden [email protected]
Take back your inbox!http://www.bunchmail.com/
Twitter/IRC: @xdg

@zoot
Copy link
Author

zoot commented Apr 11, 2013

No, I haven't tried stock standard memcached. I doubt it's TT, as per my regular test script in that bundle, using Cache::Memcached works as expected. Are there perhaps certain commands other than those supported by TT, above, required/used? I'll give vanilla memcached a whirl to test compatibility.

@zoot
Copy link
Author

zoot commented Apr 12, 2013

Ok, some progress. I installed memcached and tested my demo app with it, using both ascii and binary proto and it works! The confusing thing though, is how the module Cache::Memcached actually works when speaking memcached proto to TT and Dancer2::Session::Memcached is using it! Any idea? This bug is hiding.

False alarm, two memcached instances were running. D2:S:M only runs when memcached is set to use the ascii protocol. Errors like the following occur when using binary protocol:

Invalid magic: 67
<27 connection closed.
<27 new binary client connection.
<27 Read binary protocol data:
<27 0x67 0x65 0x74 0x20
<27 0x55 0x57 0x68 0x61
<27 0x62 0x66 0x50 0x42
<27 0x74 0x46 0x37 0x55
<27 0x35 0x71 0x66 0x6f
<27 0x63 0x73 0x76 0x6f
Invalid magic: 67
<27 connection closed.

@dagolden
Copy link
Contributor

That's really strange. All the plugin does is dispatch to the
Cache::Memcached object. The only think I could imagine could be different
could be context, maybe, but I'm really not sure.

David

On Fri, Apr 12, 2013 at 7:42 PM, Dale Gallagher [email protected]:

Ok, some progress. I installed memcached and tested my demo app with it,
using both ascii and binary proto and it works! The confusing thing though,
is how the module Cache::Memcached actually works when speaking memcached
proto to TT and Dancer2::Session::Memcached is using it! Any idea? This bug
is hiding.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-16310148
.

David Golden [email protected]
Take back your inbox!http://www.bunchmail.com/
Twitter/IRC: @xdg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant