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 8772995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:10:51+00:00 2026-06-13T18:10:51+00:00

Below is my lua script: local ckid = redis.pcall(‘get’,KEYS[1]) local meta = redis.call(‘hgetall’, ckid)

  • 0

Below is my lua script:

     local ckid = redis.pcall('get',KEYS[1])
     local meta = redis.call('hgetall', ckid)
     return {ckid, meta}

if the key does not exits for the first call I would not like to execute the second.

So…I don’t what the return value is for None. In python the return value would be None.

if ckid ~= '???????' then 
    local meta = redis.call('hgetall', ckid)
else
     local meta = 'empty'
retrun {ckid, meta}

So…how do I do this is lua?

     local ckid = redis.pcall('get',KEYS[1])
     if ckid ~= nil then
         local meta = redis.call('hgetall', ckid)
     else
         local meta = 'none'
         local ckid = 'none'
     end

     return {ckid, meta}

When using nil..

ResponseError: ERR Error running script (call to f_1400713412b0063a26eb0dc063f53a4e3be26380): user_script:12: Script attempted to access unexisting global variable 'meta'
  • 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-06-13T18:10:53+00:00Added an answer on June 13, 2026 at 6:10 pm

    If you define a Local variable with in an if statement it only exists for the if statement. Check out local variable scope in the manual.

    Try

     local ckid = redis.pcall('get',KEYS[1])
     local meta
     if ckid ~= nil then
         meta = redis.call('hgetall', ckid)
     else
         meta = 'none'
         ckid = 'none'
     end
    
     return {ckid, meta}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the Lua code below: local util = {} function util:foo(p) print (p or
Why can't this Lua function using a self : be marked local without getting:
I am finding Lua's scoping rules a bit confusing. I have submitted below, a
I have a Lua class like below. I am using json to serialize the
Below is the query I am running to get updates in last one hour.
Below is my $.ajax call, how do I put a selects (multiple) selected values
I'm creating a lua script that should run on the TI-Nspire calculator. The problem
In my Lua script I'm trying to create a function with a variable number
I got a strange problem while used luabind to return a stl::vector::iterator to lua
from the below Control Panel\Programs\Programs and Features Need the List view in the Lua

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.