UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'UfEQYwpgu44NH2q3R8msx810AHDeGC6OLx75foPPOhE=' 
WHERE 
  key_id = '138ffb358b8b4b890472f74043291a39ad2a8b3dcd8606e552174ac34ec5a60f' 
  AND (
    token = 'UfEQYwpgu44NH2q3R8msx810AHDeGC6OLx75foPPOhE=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00060