Last active
August 29, 2015 14:19
-
-
Save jorgeuriarte/a4d941172d00c5064e2f to your computer and use it in GitHub Desktop.
La primera versión (la existente) hace que si un valor se queda "colgado", nunca se borre. ¿Qué problema tiene la segunda?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def updateSetContent(hashkey, userKey, hashvalue, user){ | |
def options = this.questions[hashkey].options | |
def valuesArray = hashvalue.split(',') | |
options.each{ option -> | |
def existia = jedis.sismember(userKey, option.value) | |
def existe = valuesArray.find{ it == option.value } | |
//si el usuario la marco como respuesta, y no existia | |
if( existe && !existia ) { | |
jedis.sadd(userKey, option.value) | |
} | |
else if(!existe && existia) { | |
jedis.srem(userKey, option.value) | |
} | |
} | |
} | |
def updateSetContent(hashkey, userKey, hashvalue, user){ | |
def options = this.questions[hashkey].options | |
def valuesArray = hashvalue.split(',') | |
jedis.del userKey | |
options.each{ option -> | |
def existe = valuesArray.find{ it == option.value } | |
if( existe ) | |
jedis.sadd(userKey, option.value) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment