UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'Va9054aEXgJJL3RT2I+h0xIiIhIb4CJenh5StaFMu+w='
WHERE
key_id = '8d01f4b1e0575567176807c61785b47d72e8c75cf9a39f655ba7d0999247b055'
AND (
token = 'Va9054aEXgJJL3RT2I+h0xIiIhIb4CJenh5StaFMu+w='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)