UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'AGX5tF/31igKtDAriOY1/K1VaansdAyO8aUhJV1y+F4=' 
WHERE 
  key_id = '1a5b1178e466b1f049f0afd4f18f25df22e09f7f9ad813513304170f9264420e' 
  AND (
    token = 'AGX5tF/31igKtDAriOY1/K1VaansdAyO8aUhJV1y+F4=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00044