UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Rl6LQbssBwDEmycx5orGrj+SITFURK75HXTdz4R6wGE=' 
WHERE 
  key_id = '7cef171b6fdcba8b07350524b4f3f8f923772261afb7d0c65295758135cdd0b4' 
  AND (
    token = 'Rl6LQbssBwDEmycx5orGrj+SITFURK75HXTdz4R6wGE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032