UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'V6VZ0CPiNi7EByuoODjxAEUWHh3YNJCkpbsJCYVKSA8='
WHERE
key_id = 'c4aa21f56adb777ea79137928d5cd236a6efaa3dac9c377c707dd070781e0978'
AND (
token = 'V6VZ0CPiNi7EByuoODjxAEUWHh3YNJCkpbsJCYVKSA8='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)