UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'sKIHQvK5wz1UxGXqorl4bZR4GTtJrQ73W/p750+1U7E=' 
WHERE 
  key_id = 'b38779cecf39dce554172210af7a8abe4d47c30145066d0354e28d70129e5203' 
  AND (
    token = 'sKIHQvK5wz1UxGXqorl4bZR4GTtJrQ73W/p750+1U7E=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032