UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Kquy6YEpj+DxtHbGO0kHD8VRKmTKQeQYx/kmpX/PQ4U=' 
WHERE 
  key_id = '683376f499f6f789ebb03241a1f1136d058bf3da1826a5729e22796640ff9495' 
  AND (
    token = 'Kquy6YEpj+DxtHbGO0kHD8VRKmTKQeQYx/kmpX/PQ4U=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032