Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5938945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:45:24+00:00 2026-05-22T15:45:24+00:00

Using redis-rb in a Rails app, the following doesn’t work: irb> keys = $redis.keys(autocomplete*)

  • 0

Using redis-rb in a Rails app, the following doesn’t work:

irb> keys = $redis.keys("autocomplete*")
=> ["autocomplete_foo", "autocomplete_bar", "autocomplete_bat"]
irb> $redis.del(keys)
=> 0

This works fine:

irb> $redis.del("autocomplete_foo", "autocomplete_bar")
=> 2

Am I missing something obvious? The source is just:

# Delete a key.
def del(*keys)
  synchronize do
    @client.call [:del, *keys]
  end
end

which looks to me like it should work to pass it an array…?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:45:25+00:00Added an answer on May 22, 2026 at 3:45 pm

    A little coding exploration of the way the splat operator works:

    def foo(*keys)
      puts keys.inspect
    end
    
    >> foo("hi", "there")
    ["hi", "there"]
    
    >> foo(["hi", "there"])
    [["hi", "there"]]
    
    >> foo(*["hi", "there"])
    ["hi", "there"]
    

    So passing in a regular array will cause that array to be evaluated as a single item, so that you get an array inside an array within your method. If you preface the array with * when you call the method:

    $redis.del(*keys)
    

    That lets the method know to unpack it/not to accept any further arguments. So that should solve the problem that you’re having!

    Just for the sake of further clarification, this works:

    >> foo("hello", *["hi", "there"])
    

    This causes a syntax error:

    >> foo("hello", *["hi", "there"], "world")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Rails with redis. From the introduction of Redis, I found such information:
I'm using Rails with Resque. I know the command of redis-cli is: expire key
How can I implement an autocomplete using redis? Say for example I have an
I am just trying to walk through this tutorial http://jimneath.org/2011/03/24/using-redis-with-ruby-on-rails.html#redis_and_rails And when I put
I am hosting a rails 3 app on a cloud VPS using apache passenger
I'm building a simple real time chat using Juggernaut, Redis, SQLite and Rails 3.1
I'm trying to deploy a Rails app on an Apache2 server by using Phusion
Is it possible to persist only certain keys to disk using Redis? Is the
We're using Redis for monitoring on a high traffic web application. The app is
I have the following problem: I'm using Redis with NodeJS together via mranney's driver

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.