redis 스크립트 처리방법

image_pdfimage_print

LUA 스크립트를 활용해서 redis console 에서 처리하는 예제를 아래 남깁니다.

레디스 hash 에서 특정코드 검색해서 삭제하는 방법입니다

EVAL "
local hash_key = KEYS[1]
local condition = ARGV[1]

local fields = redis.call('HKEYS', hash_key)
local result = {}
for _, field in ipairs(fields) do
    local value = redis.call('HGET', hash_key, field)
    local startpos, endpos = string.find(value, condition)
    if startpos then
		redis.call('HDEL', hash_key, field)
		result[#result + 1] = field
    end
end
return result
" 1 test '24002'

test 해시키의 값에 24002 값이 있으면 삭제하고, 해당 필드값을 화면에 표시합니다.

다만, 해시 필드를 모두 가져와서 검색하기 때문에 느립니다.

하나의 세션을 잡기때문에 전체 성능에 영향은 주지 않을 것 같으나 검토는 필요합니다.

프로그램으로 안짜고, redis console 에서 실행할 수 있다는 것이 장점인데, 검색키워드 (condition) 에 날짜문자열(2024-04-20)를 줬는데 검색이 안되더라구요. 충분한 테스트가 필요할 듯 하네요.

21 thoughts on “redis 스크립트 처리방법

  1. Fascinating to see how gaming adapts to local tastes! The Filipino approach, like what philwin app offers with GCash & familiar vibes, is smart. It’s about more than just games, it’s about community & accessibility! Really interesting stuff.

  2. Solid analysis of tournament dynamics! Thinking about maximizing your edge… reminds me of striving for “boss-level” play. Checking out jili boss – their focus on a premium experience & fast loading times could translate to quicker decision-making at the tables, right? 🤔

  3. That’s a great point about balancing accessibility with depth in shooting games! Seeing platforms like jl boss vip focus on smooth onboarding and security is promising – crucial for new players, honestly. It’s all about building trust!

  4. Interesting article! Seeing more platforms like 2jl cater specifically to the Philippine market is great. Easy access via the 2jl app download & local payment options like GCash are key for a smooth experience. Definitely a growing scene!

  5. It’s fascinating how quickly online platforms are evolving to cater to player needs – instant transactions are key! Seeing options like GCash & crypto on ubet95 legit really shows that focus. Responsible gaming is crucial though, always remember to set limits!

  6. Interesting read! Seeing more platforms like vvjl club really boosts the Philippine gaming scene. Quick registration & those PHP payment options are key – makes it so accessible! Hoping for big wins! ✨

  7. It’s smart to approach online casinos with a clear head – understanding why we play is key. Pesowin seems to prioritize that, focusing on wellbeing. If you’re curious, check out pesowin download – responsible gaming is a must! It’s about fun, not stress.

  8. PokerNowClub is great if you’re looking for a fun place to play poker with friends online. I really enjoy the simplicity of setting up a table and playing rounds. A very popular platform for those who love to play card games. Feel free checking out their site: pokernowclub

vvjl에 답글 남기기 응답 취소

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다