UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'n3vAasFry+HbXIY59wyOUz9mAPq2Low7KtxgeT+kw6Q=' 
WHERE 
  key_id = '1866012a29a3209e6e0c458717df23d5e10af4c53166b30228ba5185b4e1ee26' 
  AND (
    token = 'n3vAasFry+HbXIY59wyOUz9mAPq2Low7KtxgeT+kw6Q=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00035