UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'IIm1YuorGCzpnlfBdDRFRDKFu9f3HD3+vg47v9yo/Cs=' 
WHERE 
  key_id = '8c240c9fd203b819e7bd1658257729d08046597eba231f2ef489941dd36a6f67' 
  AND (
    token = 'IIm1YuorGCzpnlfBdDRFRDKFu9f3HD3+vg47v9yo/Cs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00025