If you're having a problem, stop hiding the diagnostics. Use use strict; use warnings;! They wouldn't have helped here (except to detect unrelated issues), but you didn't know that.

I love how you repeat that it works for arrays and it doesn't work for arrays. The problem is surely in the question.

Your code is equally fishy.

$memd->set("mem_id_cache", \@array); ^^^^^^^ scalar @tmp = $memd->get("mem_id_cache"); ^^^^ array

Why do you expect to get something different than you put in?

Storing @array yeilds nothing.

I'm curious as to how you tested that since functions can only take scalars as arguments.

Passing the contents of the array is obviously wrong too, since the documentation that says you must supply *a* scalar for the value.

Since you can't change what you store, you need to change what you expect to fetch.

my @items_to_stored = qw( a b c ); $memd->set("mem_id_cache", \@items_to_stored); my $stored_items = $memd->get("mem_id_cache"); print "$_\n" for @$stored_items;

In reply to Re: Memcached and arrays? by ikegami
in thread Memcached and arrays? by expresspotato

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.