UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'KSBzHl45v3lc5+MtDO+VW1ggqXLOF8eFFNFiebR0TR8='
WHERE
key_id = '8ca65ca7916968b080020c4992c765e487842a0b2a987e1abbe1ba82906c19ca'
AND (
token = 'KSBzHl45v3lc5+MtDO+VW1ggqXLOF8eFFNFiebR0TR8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)