UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'J8tGC4n5lO3Hssc3S2CxXoFAjIFjOsleA169QHcdJJU=' 
WHERE 
  key_id = '3a7fa4317a7e5f5d9bfed504c9089f471cef409ee224277dd94d00180d157671' 
  AND (
    token = 'J8tGC4n5lO3Hssc3S2CxXoFAjIFjOsleA169QHcdJJU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040