UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'O1fltqMPa38xg7MHKkpm4+26vltoXcXetkwj5cni4Wo=' 
WHERE 
  key_id = '29e75783f68a3cb6a5bdea8cbe8ddd2920d529de36394eca55a8e538ca637be8' 
  AND (
    token = 'O1fltqMPa38xg7MHKkpm4+26vltoXcXetkwj5cni4Wo=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00041